<!--检查预约登记-->
<template>
  <div class="his_container">
    <!-- <el-input
      style="display: none;"
      v-model="formdata.none"
      @keyup.enter.native="search"
    ></el-input> -->
    <div>
      <div class="his_cont">
        <div class="apply_form" ref="apply_form">
          <el-form
            rel="form"
            :model="formdata"
            :inline="true"
          >
            <el-form-item>
              <div
                class="more_btn"
                :class="{more_btn_active: formMoreOpen}"
                title="切换查询条件样式"
                @click="tiggerFormMoreOpen">
                <i :class="formMoreOpen?'fa fa-navicon':'fa fa-th-large'"></i>
              </div>
            </el-form-item>
            <el-form-item v-if="formMoreOpen">
              <el-select
                size="mini"
                v-model="appoint_type"
                placeholder="预约来源"
                style="width: 100px;"
                @change="appointTypeChange"
              >
                <el-option
                  v-for="(item, index) in appointTypeOptions"
                  :disabled="appointSourceFlag && (appointSourceNameList || ['自助预约','移动预约']).includes(item)&&(!$hasPermission(['YJYY10008098']))"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="areaNameShow">
              <el-select
                size="mini"
                v-model="formdata.areaName"
                clearable
                placeholder="院区"
                style="width: 120px;"
                @change="areaNameChange"
              >
                <el-option
                  v-for="(item, index) in areaNameOptions"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="depAreaShow">
              <el-select
                size="mini"
                v-model="formdata.depArea"
                clearable
                placeholder="影像区域"
                style="width: 120px;"
                @change="depAreaChange"
              >
                <el-option
                  v-for="(item, index) in depAreaOptions"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <!-- queryWayChange -->
            <el-form-item prop="patientSource">
              <div class="pat_source">
                <el-radio-group
                  :disabled="isDisabled || isDisabledByTest"
                  v-model="formdata.patientSource"
                  @change="patSourceChange"
                >
                  <el-radio
                    v-for="item in patSourceOptions"
                    :key="item.value"
                    :label="item.value"
                  >{{item.name}}</el-radio>
                </el-radio-group>
              </div>
            </el-form-item>
            <el-form-item prop="dateRadio">
              <el-date-picker
                v-if="isMpiOrPid == true ? isMpiOrPid : formMoreOpen"
                v-model="formdata.hisFormDate"
                type="daterange"
                size="mini"
                unlink-panels
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :clearable="false"
                :picker-options="pickerOptions"
                style="max-width: 210px;width: 100%;vertical-align: 2px;"
                @change="hisFormDateChange"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <div class="pat_source">
                <el-radio-group
                  v-model="formdata.dateRadio"
                  @change="dateRadioChange"
                >
                  <el-radio
                    v-for="(item, index) in dateRadioOptions"
                    :key="index"
                    :label="item.value">{{item.label}}</el-radio>
                </el-radio-group>
              </div>
            </el-form-item>
            <el-form-item>
              <el-select
                size="mini"
                v-if="!isChooseDeps"
                v-model="formdata.executeDepartMent"
                placeholder="检查部门"
                clearable
                style="width: 120px;"
                @change="handleExecuteDepartMentChange"
              >
                <el-option
                  v-for="(item, index) in depOptions"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-select
                v-if="isChooseDeps"
                size="mini"
                v-model="formdata.executeDepartMents"
                placeholder="检查部门"
                @change="handleExecuteDepartMentChange"
                multiple
                clearable
                :collapse-tags="collapseShow"
                style="width: 150px;"
              >
                <el-option
                  v-for="(item, index) in depOptions"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="isShowApplyDepart">
              <el-select size="mini" v-model="formdata.applyDepartment" placeholder="申请科室" :disabled="isDisabled" clearable allow-create style="width: 120px;" @change="handleApplyDepartMentChange">
                <el-option v-for="(item, index) in departmentOptions" :key="index" :label="item" :value="item"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="isShowWardNo">
              <el-select size="mini" v-model="formdata.wardNo" placeholder="病区" clearable style="width: 120px;" @change="handleWardNoChange">
                <el-option v-for="(item, index) in wardNoOptions" :key="index" :label="item" :value="item"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item v-if="modalitytypeShow">
              <el-select
                size="mini"
                v-model="formdata.modalitytype"
                clearable
                placeholder="设备类型"
                style="width: 100px;"
                @change="modalitytypeChange"
              >
                <el-option
                  v-for="(item, index) in modalitytypeOptions"
                  :key="index"
                  :label="item"
                  :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-input
                size="mini"
                ref="patientName"
                v-if="!isHideNameSearch"
                v-model="formdata.patientName"
                placeholder="患者姓名"
                @keyup.enter.native="search"
                clearable
                autocomplete="off"
                style="width: 120px;"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-input
                id="formQueryTextIpt"
                ref="formQueryTextIpt"
                size="mini"
                v-model="formdata.queryText"
                placeholder=""
                clearable
                style="width:260px;margin-right: 5px;"
                @input="changeInput"
                @keyup.enter.native="search"
              >
                <el-select
                  slot="prepend"
                  size="mini"
                  v-model="formdata.queryWay"
                  placeholder="请选择"
                  style="width: 100px;"
                  @change="queryWayChange"
                >
                  <el-option
                    v-for="(item, index) in queryWayOptions"
                    :key="index"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-input>
            </el-form-item>
            <el-form-item>
              <div class="ky-inlineblock ky-vertical-top flex flex-row">
                <el-button
                  type="primary"
                  size="mini"
                  :loading="loading"
                  @click="search"
                  style="width: 70px;"
                >
                  查询
                </el-button>
                <WSCardReader class="mar-l-5" ref="WSCardReader" btn-size="mini" @getWSCardReaderMsg="getWSCardReaderMsg"/>
                <el-button
                  size="mini"
                  @click="resetBtn"
                  style="margin-left:5px;width: 70px;"
                  plain
                >
                  重置
                </el-button>
                <div class="mar-l-8 flex align-center">
                  <div v-if="cancelShow">
                    <el-checkbox class="mar-r-6" v-model="formdata.cancel" @change="filterList">过滤已取消</el-checkbox>
                  </div>
                  <div v-if="formdata.patientSource === 2 && isConfigBedside">
                    <el-checkbox class="mar-r-6" v-model="formdata.bedside" @change="filterList">床旁</el-checkbox>
                  </div>
                  <div v-if="!(appointSourceFlag && (appointSourceNameList || ['自助预约','移动预约']).includes('检查科室')&&(!$hasPermission(['YJYY10008098']))) && appointTypeOptions && appointTypeOptions .length != 1 && appointTypeOptions.filter(item => item === '检查科室').length > 0">
                    <el-checkbox class="mar-r-6" v-model="formdata.fromCheckDepartment" @change="appointTypeCheck">强制预约</el-checkbox>
                  </div>
                </div>
              </div>
            </el-form-item>
          </el-form>
        </div>
        <div class="his_table">
          <div class="grid_tit flex flex-row justify-between">
            <div class="flex flex-row align-center">
              <div class="grid-tit-tip flex flex-row justify-start align-end">
                <b>查询结果</b>
                <b v-if="mix_saveDATA && mix_saveDATA.length < listLimit">
                  ({{mix_saveDATA && mix_saveDATA.length || 0}})
                </b>
                <el-tooltip v-else class="item" effect="dark" :content="`为了提升浏览器性能，查询申请单的数据上限暂定为${listLimit || 500}条`" placement="right">
                  <b>
                    ({{mix_saveDATA && mix_saveDATA.length || 0}})
                  </b>
                </el-tooltip>
                <span class="tips mar-l-3">支持多选联合预约</span>
              </div>
              <div class="grid_tit_ckb mar-l-10" v-if="formdata.patientSource === 2">
                <el-checkbox v-if="returnedShow" v-model="formdata.returned" @change="filterList">已退单</el-checkbox>
                <el-checkbox v-if="unregisteredSHow" v-model="formdata.unregistered" @change="filterList">未登记</el-checkbox>
              </div>
              <div class="grid_tit_ckb mar-l-10" v-if="formdata.patientSource === 3 && isShowApplyListRefresh">
                <el-checkbox v-model="isAutoRefresh" @change="changeIsAutoRefresh">实时刷新</el-checkbox>
              </div>
            </div>
            <div class="flex justify-end" v-if="hisActivedIndex == 1 || hisActivedIndex == 3">
              <el-button v-if="(checkedPatId || isSelectedRow) && routerPath === '/cancelApplyHIS'" v-permission="'YJYY100070002'" size="mini" @click="cancelHisApply">取消HIS申请单</el-button>
              <el-button v-if="checkedPatId" size="mini" @click="cancelCheckedChange">取消选择</el-button>
              <!-- <el-button
                v-show="checkedPatId || isSelectedRow"
                type="primary"
                size="mini"
                @click="appointmentPostMessageUnion"
              >联合预约</el-button> -->
            </div>
            <!-- <div style="clear: both;"></div> -->
          </div>
          <!-- v-herticalDrag="hisTableHeight +'px'" :style="{ height: hisTableHeight + 'px'}" -->
          <div class="el-table-wrappers" v-herticalDrag="hisTableHeight +'px'" :style="{ height: hisTableHeight + 'px'}" v-loading="loading">
            <el-table
              ref="tableRef"
              :data="mix_tableData"
              border
              style="width: 100%"
              class="ky-table"
              :cell-class-name="textUnderLine"
              :row-class-name="tableRowClassName"
              :row-style="tableRowStyle"
              @row-click="handleRowCurr"
            >
              <!-- highlight-current-row -->
              <el-table-column width="36" type="index" :index="0" v-if="hisActivedIndex == 1 || hisActivedIndex == 3">
                <template slot="header" slot-scope="{$index}">
                  <!-- 上面的 slot-scope 修复 全选复选框 点击交互没效果的问题 -->
                  <!-- 查询方式 0-病人id 1-卡号 2-门诊号 3-住院号 4-发票号 5-申请单号 6-身份证号 7-社保卡号 暂时不用 8-手机号 默认0 -->
                  <div>
                    <el-checkbox
                      :disabled="!(checkedPatId || ((formdata.queryText) && formdata.queryWay !== 8 && formdata.queryWay !== 4))"
                      :indeterminate="isIndeterminate"
                      v-model="checkAll"
                      :index="$index"
                      @change="handleCheckAllChange"></el-checkbox>
                  </div>
                </template>
                <template slot-scope="scope">
                  <div style="position: relative;" :class="isLineThrough && !scope.row.feeStatus ? 'text-underline': ''">
                    <!-- examStatus 值域：0-已登记；1-已检查；2-已报告；3-已审核；4-已作废；5-原始； -->
                    <!-- checkedPatId && checkedPatId !== scope.row.patientId 为了判断患者ID是否为查询目标，若否，则disable勾选框 -->
                    <el-checkbox
                      :disabled="(!!checkedPatId && checkedPatId !== scope.row.patientId) || (isCheckExamStatus && scope.row.examStatus >= 0 && scope.row.examStatus <= 3)"
                      v-model="mix_tableData[scope.$index].checked"
                    ></el-checkbox>
                    <div style="width: 100%;height: 100%;position:absolute;top: 0; left: 0;z-index: 1;cursor: pointer;background:rgba(255,255,255,0);"></div>
                  </div>
                </template>
              </el-table-column>
              <el-table-column width="35" label="" align="center" v-if="isHideApplyInfoBoxAndUseDialog">
                <template slot-scope="scope">
                  <div class="flex justify-center align-center">
                    <el-button type="text" size="mini" @click.stop="detail(scope.row)">详</el-button>
                  </div>
                </template>
              </el-table-column>
              <el-table-column width="35" label="" align="center" v-if="(applyInfoHospital === 'wzszxyy' || hospitalCode === '47052555733030211A1001') && isShowDayTag">
                <template slot-scope="scope">
                  <div class="flex justify-center align-center" :class="isLineThrough && !scope.row.feeStatus ? 'text-underline': ''">
                    <!-- 模糊查询 -->
                    <span>{{(scope.row && scope.row.applyDepartment && scope.row.applyDepartment.includes('住院服务中心')) || (scope.row && scope.row.wardName && scope.row.wardName.includes('住院服务中心')) ? '日' : ''}}</span>
                  </div>
                </template>
              </el-table-column>
              <!-- <el-table-column prop="patientName" label="患者" min-width="90" show-overflow-tooltip>
                <template slot-scope="scope">
                  <span class="pat_name" @click="showPatInfo(scope.row)">{{scope.row.patientName}}</span>
                </template>
              </el-table-column> -->
              <el-table-column type="expand" v-if="((applyInfoHospital === 'wzszxyy' || hospitalCode === '47052555733030211A1001') && userDepartment ==='超声科') || $hasPermission['YJYY10008056']">
                <template slot-scope="scope">
                  <div class="nested-table-container" style="overflow-y: auto;">
                    <el-table :row-style="{background:'rgb(230, 249, 253)'}" :header-cell-style="{background:'rgb(128, 224, 247)'}" ref="multipleTable" :data="scope.row.orderBillInfo" style="width: 56%;" :style="{ 'height': getHeight(scope.row.orderBillInfo) }">
                      <!-- 子表格的列 -->
                      <el-table-column width="36" type="index" :index="0">
                        <template slot="header" slot-scope="{$index}">
                          <!-- 上面的 slot-scope 修复 全选复选框 点击交互没效果的问题 -->
                          <!-- 查询方式 0-病人id 1-卡号 2-门诊号 3-住院号 4-发票号 5-申请单号 6-身份证号 7-社保卡号 暂时不用 8-手机号 默认0 -->
                          <div>
                            <el-checkbox
                              v-model="scope.row.orderCheckedAll"
                              :index="$index"
                              :indeterminate="scope.row.orderCheckedHalf"
                              @change="handleBillCheckedAll(scope.row, scope.row.orderCheckedAll)"></el-checkbox>
                          </div>
                        </template>
                        <template slot-scope="{$index}">
                          <div style="position: relative;">
                            <el-checkbox
                              v-model="scope.row.orderBillInfo[$index].checked"
                              :index="$index"
                              @change="handleBillChecked(scope.row, $index, scope.row.orderBillInfo[$index].checked)"
                            ></el-checkbox>
                            <div style="width: 100%;height: 100%;position:absolute;top: 0; left: 0;z-index:-1;cursor: pointer;background:rgba(255,255,255,0);"></div>
                          </div>
                        </template>
                      </el-table-column>
                      <el-table-column prop="billName" label="费用名称" align="left" width="210" :resizable="true"></el-table-column>
                      <el-table-column label="检查名称" align="left" width="150" :resizable="true">
                        <template slot-scope="{$index}">
                          <div>
                            {{scope.row.orderBillInfo && scope.row.orderBillInfo != null ? scope.row.examItems.filter(item => item.examItemNo === scope.row.orderBillInfo[$index].examItemNo)[0].examItemName : ''}}
                          </div>
                        </template>
                      </el-table-column>
                      <el-table-column prop="price" label="总价" align="left" width="80"></el-table-column>
                      <el-table-column prop="amount" label="数量" align="left" width="50"></el-table-column>
                      <el-table-column prop="billCode" label="医疗序号" align="left" width="110"></el-table-column>
                      <el-table-column prop="examItemNo" label="医技序号" align="left" width="110"></el-table-column>
                    </el-table>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                v-for="(cc, index) in tableColumns"
                :key="index"
                :prop="cc.prop"
                :label="cc.label"
                :width="cc.width"
                show-overflow-tooltip>
              </el-table-column>
              <!-- <el-table-column>
                <template slot-scope="scope">
                  {{checkedPatId}}/{{scope.row.patientId}}
                </template>
              </el-table-column> -->
              <!-- <el-table-column
                fixed="right"
                label="操作"
                width="100">
                <el-button type="text" size="small">查看</el-button>
              </el-table-column> -->
            </el-table>
            <div class="draggerVbar" ref="resizebar"></div>
          </div>
        </div>
      </div>
      <!-- 病历信息 -->
      <!-- <div v-if="isShowMedicalRecord">
        <applyMRITable ref="applymriState"></applyMRITable>
      </div> -->
      <dialogDrawer
        :ddtvisible="ddtvisible"
        :direction="direction"
        @close="close"
        v-if="isHideApplyInfoBoxAndUseDialog">
        <applyInfoForWenZhouCenterH :row-curr="rowCurr" :mip-visible="mipVisible"></applyInfoForWenZhouCenterH>
      </dialogDrawer>
      <template v-else>
        <AppInfoForFuding :row-curr="rowCurr" :mip-visible="mipVisible" v-if="applyInfoHospital=='fuding' || hospitalCode == '12352203490467403B'"></AppInfoForFuding>
        <AppInfoForCommon :row-curr="rowCurr" :mip-visible="mipVisible" :is-config-bedside="isConfigBedside" v-else></AppInfoForCommon>
      </template>
    </div>
    <!-- <setTableConfig ref="setTableConfig" from="userTable"/> -->
    <commonTipDialog :dialog-tip-visible="dialogTipVisible" :content="tipContent" @closeTipEvent="closeTipEvent"></commonTipDialog>
  </div>
</template>

<script>
/* eslint-disable */
import { setLocalStorage, getLocalStorage } from '@/utils/localStorage' // removeLocalStorage
import { postHisExamEncrypt, getSysHospitalGetModelByCode, getDepList, getItemList } from '@/api/api'
import { getModalityTypeListFunc } from '@/api/common'
import { dateFormatter } from '@/utils/validate'
import { isNull, getDateYMD, getKyReaderCardOptions, getIsShowTwoList, getIsSetStorageAreaName, getIsAutoRefresh,
  setIsAutoRefresh, setHISRecordDialogMemory, diffDay, getQueryWayByText
} from '@/utils/utils'
// import setTableConfig from './setTableConfig'
import enc from '@/utils/aes'
// import aes from '@/utils/aes'
import commonTipDialog from '@/components/dialog/commonTipDialog'
import AppInfoForCommon from '@/views/appointCenter/components/applyInfoForCommon.vue'
import AppInfoForFuding from '@/views/appointCenter/components/applyInfoForFuding.vue'
import applyInfoForWenZhouCenterH from '@/views/appointCenter/components/applyInfoForWenZhouCenterH.vue'
import dialogDrawer from '@/components/dialogbox/dialogDrawer'
import WSCardReader from '@/components/WSCardReaderNew/index'
import rtUtil from '@/components/WSCardReaderNew/readerType'
// import applyMRITable from './applyMRI.vue'
import { Options } from '@/utils/constant'
import { mapGetters } from 'vuex'
import bus from '@/api/bus'
import store from '@/store'
import applyInfo from '@/mixin/applyInfo'
import virtualTableJs from '@/mixin/virtualTable'
import applyFunction from '@/mixin/applyFunction'
const CHECK_FORM_DEFAULT_KEY = 'CHECK_FORM_DEFAULT'
import pinyin from 'js-pinyin'
let string =  '' // getLocalStorage('localSetMemory') || `{"modalitytype":"","depArea":"","areaName":"","dep":"","deps":[]}`
let logoutFlag = localStorage.getItem('logoutFlag') // 此参数无需根据医院代码来存储，一体化跳转过来单点登录的时候使用的
let localSetMemoryObj = '' // JSON.parse(string)
let searchInterval = ''
let doSearchArr = {
  'all': {
    requestTime: new Date().getTime(),
    responseTime: new Date().getTime()
  },
  'some': {
    requestTime: new Date().getTime(),
    responseTime: new Date().getTime()
  }
}
export default {
  components: {
    WSCardReader,
    // applyMRITable,
    AppInfoForCommon,
    AppInfoForFuding,
    applyInfoForWenZhouCenterH,
    // setTableConfig,
    dialogDrawer,
    commonTipDialog
  },
  mixins: [virtualTableJs, applyFunction, applyInfo],
  props: {
    checkUrl: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      tipContent: '',
      dialogTipVisible: false,
      isDisabledByTest: false, // 中心医院体检的患者类型判断患者类型是否禁止被点击的状态
      isSelectedRow: false,
      isDisabled: false,
      isSaveInput: false,
      collapseShow: false,
      appointSourceNameList: window.g.appointSourceNameList,
      userDepartment: this.$store.state.user.deptName, // 申请单科室
      isAutoRefresh: false,
      isConfigBedside: false,
      isAlreadyShow: false,
      setOverBed: {},
      isHideNameSearch: window.g.isHideNameSearch,
      appointSourceFlag: window.g.appointSourceFlag,
      tableDataShowAll: [],
      mipVisible: false,
      isMpiOrPid: window.g.isMpiOrPid,
      isVIP: false, // 是否勾选VIP
      isJZ: false, // 是否勾选急诊
      wsType: '',
      direction: (window.g.applyHis && window.g.applyHis.applyInfoShowPosition) || 'btt',
      ddtvisible: false,
      queryWayOptions: Options.queryWayOptions, // 查询方式 0 病人id 1 卡号 2 门诊号 3 住院号 4 发票号 5 申请单号 6 身份证号 7 社保卡号 暂时不用 8 手机号 默认0
      isHideApplyInfoBoxAndUseDialog: (window.g.applyHis && window.g.applyHis.isHideApplyInfoBoxAndUseDialog) || false,
      applyInfoHospital: window.g.applyInfoHospital || '',
      isShowTestInfo: window.g.isShowTestInfo || false,
      kyCardReaderOptions: '',
      hisTableHeight: ~~(getLocalStorage('yjyy-hisTableHeight')) || 348,
      remarkInfo: '',
      // isCheckExamStatus: this.$store.state.user.appSetting.isCheckExamStatus,
      isSetGrade: this.$store.state.user.appSetting.isSetGrade,
      isSetRemarkInfo: window.g.IS_SET_REMARKINFO,
      pubcliKey: this.$store.state.user.pubcliKey,
      privateKey: this.$store.state.user.privateKey,
      loading: false,
      isEncrypt: true,
      userName: this.$store.state.user.userName,
      userCode: this.$store.state.user.userCode,
      hospitalCode: this.$store.state.user.hospitalCode,
      hospitalName: this.$store.state.user.hospitalName,
      // depArea: window.g.CHECK_APPLY_DEPAREA,
      // areaName: '',
      isWSCardReader: false, // 判断当前查询，是否为刷卡
      tableDataAll: [],
      isToSearch: true,
      isFocusRadio: false,
      tableData: [],
      formMoreOpen: true, // 是否展开更多查询条件
      formdata: {
        hisFormDate: [getDateYMD(new Date().getTime() - 6 * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())],
        queryText: '',
        fromCheckDepartment: false,
        examClass: '',
        patientName: '',
        executeDepartMents: [],
        applyDepartment: getLocalStorage('yjyy@applyDepart') || '',
        wardNo: getLocalStorage('yjyy@wardno') || '',
        executeDepartMent: getLocalStorage('yjyy@executeDepart') || '',
        patientSource: window.g.isDefinePatSource == 0 || window.g.isDefinePatSource ? window.g.isDefinePatSource : 1, // 病人类型 1-门诊 2-住院 3-体检 4-绿检 5急诊 6外院、0未知 默认0
        queryWay: !window.g.IS_TRIGGER_OUTPATIENT ? 1 : 2, // 查询方式 0-病人id 1-卡号 2-门诊号 3-住院号 4-发票号 5-申请单号 6-身份证号 7-社保卡号 暂时不用 8-手机号 默认0
        dateRadio: '7', // 查询时间，7天，14天 30天 8qwayResult
        depArea: '', // 影像区域过滤
        areaName: '', // 院区过滤
        modalitytype: getLocalStorage('yjyy@modalitytype') || '', // 设备类型过滤yjyy@modalitytype
        cancel: false, // 已取消过滤
        unregistered: false, // 未登记
        returned: false, // 已退单
        none: ''
      },
      checkAll: false,
      isIndeterminate: false,
      // rowCurr: {},
      selectRowIds: [],
      checkedPatId: '',
      applyCodes: '',
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 6)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 29)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 89)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一年',
          onClick(picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 364)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近十年',
          onClick(picker) {
            let end = new Date()
            let start = new Date()
            start.setFullYear(start.getFullYear() - 10)
            picker.$emit('pick', [start, end])
          }
        }]
      },
      dateRadioOptions: [
        { label: '1天', value: '1' },
        { label: '3天', value: '3' },
        { label: '7天', value: '7' },
        // { label: '14天', value: '14' },
        { label: '30天', value: '30' }
      ],
      // depAreaOptions: [], // 院区(影像区域)
      // areaNameOptions: [],
      modalitytypeOptions: [], // 设备类型
      depOptions: [], //  科室列表
      // departmentOptions: [], // 申请科室
      inpatientWardOptions: [], // 病区
      // 急诊标志
      // emergencyTypes: Options.emergencyOptions,
      // patientSourceOptions: Options.patientTypeItemOptions.concat([{ label: '全部', value: 0 }]),
      appoint_pst: window.g.APPOINT_PST, // [1, 2, 3], // 预约患者类型，默认展示类型 pst:patientsourcetypes
      // 检查预约
      // appointTypeOptions: window.g.APPOINT_TYPE_OPTIONS || ['前台登记', '临床预约'], // 预约类型选项
      appoint_type: window.g.APPOINT_DEFAULT_TYPE || '前台登记', // 预约类型
      appoint_url: window.g.APPOINT_URL ? window.g.APPOINT_URL + '/index.html?isLogo=1' : '',
      dialogCheckAppoVisible: false,
      isShowMedicalRecord: window.g.isShowMedicalRecord,
      // 门诊、内窥镜， 显示病历信息配置
      MRI_examClass: ['内窥镜', '胃肠镜', '胃镜', '肠镜'],
      // 配置显示问题
      lcLoaded: false,
      lcPostMsgList: [],
      // 表格的列显示
      columnsConfig: Options.checkTableColumnsConfig,
      // 取消勾选清空右侧内容
      refreshIframeContent: false,
      encryptData: null,
      isShowTwoList: false,
      isSetStorageAreaName: false,
      isShowDayTag: false, // 是否展示日间手术的提示列
      tableColumns: [],
      oldRow: {},
      tableColumnTest: [],
      applyCodeFrom: [],
      appointTypeOptions: []
    }
  },
  computed: {
    ...mapGetters(['wardNoOptions', 'hisActivedIndex', 'isCheckExamStatus', 'rowCurr', 'websoketIsOpen', 'departmentOptions', 'depAreaOptions', 'areaNameOptions']),
    routerPath() {
      console.log('this.$route.path', this.$route.path)
      return this.$route.path
    },
    appConfig() {
      return this.$store.state.settings.appConfig
    },
    numSpliceIsFront() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.numSpliceIsFront
    },
    // jskQueryWay() {
    //   return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.jskQueryWay
    // },
    hisIsSelectAll() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.hisIsSelectAll
    },
    defHisDay() {
      return (this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.defHisDay) || 3650
    },
    isChooseDeps() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.isChooseDeps
    },
    isClearQueryText() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.isClearQueryText
    },
    isBedNoSort() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.isBedNoSort
    },
    isCloseHisAndConfigLink() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.isCloseHisAndConfigLink
    },
    // applyInfoCancelUseDialog() {
    //   return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.applyInfoCancelUseDialog
    // },
    tijianTotijianhao() {
      return (this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.tijianTotijianhao) || window.g.tijianTotijianhao
    },
    stestIDMergeOutID() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.stestIDMergeOutID
    },
    patSourceOptions() {
      let patientSourceOptions = (this.appConfig.checkPatTypeTable || Options.patientTypeItemOptions).concat([{ label: '全部', value: 0 }])
      let psArr = []
      patientSourceOptions.forEach(item => {
        item.name = item.label || item.name
        delete item.label
        psArr.push(item)
      })
      let arr = this.operatorPatSourceOption(psArr)
      return arr
    },
    applyCheckUrl: {
      get() {
        return this.checkUrl
      },
      set(val) {
        this.$emit('update:checkUrl', val)
      }
    },
    paramConfig() {
      return this.$store.state.settings.paramConfig
    },
    // 列表配置
    // tableColumns(val) {
    //   const _t = this.appConfig && this.appConfig.checkHisTableColumnsConfig ? this.appConfig.checkHisTableColumnsConfig : this.columnsConfig
    //   _t.forEach(item => {
    //     if (item.prop == 'bedside' && item.show) {
    //       this.isConfigBedside = true
    //     }
    //   })
    //   return _t.filter(c => c.show).sort((a, b) => {
    //     return a.sort - b.sort
    //   })
    // },
    // 已取消过滤
    cancelShow() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.cancelType
    },
    isLineThrough() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.isLineThrough
    },
    // 设备过滤
    modalitytypeShow() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.modalityType
    },
    isShowApplyDepart() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.isShowApplyDepart
    },
    isShowWardNo() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.isShowWardNo
    },
    // 影像区域过滤
    depAreaShow() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.depArea
    },
    areaNameShow() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.areaName
    },
    // 不自动自动查询的患者来源
    notAutoSearchPatSource() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.unSearchAutoPatientSource
    },
    isShowApplyListRefresh() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.isShowApplyListRefresh
    },
    // 未登记过滤
    unregisteredSHow() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.unregistered
    },
    // 已退单过滤
    returnedShow() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.returned
    },
    isUnregistered() {
      return (this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.isUnregistered) || window.g.isUnregistered
    },
    applyDepartmentCodeFilterArr() {
      return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.applyDepartmentCodeFilterArr
    },
    // applyDepartmentFilterArr() {
    //   return this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.applyDepartmentFilterArr
    // },
    // isShowTwoList() {
    //   return
    //   // return this.appConfig &&
    //   //   this.appConfig.baseConfig &&
    //   //   this.appConfig.baseConfig.isShowTwoList
    // },
    IS_TRIGGER_PATIENTID() {
      return (this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.IS_TRIGGER_PATIENTID) || window.g.IS_TRIGGER_PATIENTID
    },
    KYCARDREADER_OPTIONS() {
      // console.log('this.appConfig.baseConfig', this.appConfig.baseConfig)
      let arr = ((this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.kyReaderCardNameArr && this.appConfig.baseConfig.kyReaderCardNameArr.length) && this.appConfig.baseConfig.kyReaderCardNameArr) || []
      // console.log('arr', arr)
      let options = getKyReaderCardOptions(arr)
      // console.log('KYCARDREADER_OPTIONS=>options', options)
      return (options.length && options) || window.g.KYCARDREADER_OPTIONS || window.g.KYCARDREADER_OPTIONS_FUDING
    },
    listLimit() {
      return this.appConfig &&
        this.appConfig.baseConfig &&
        this.appConfig.baseConfig.listLimit
    }
  },
  async created() {
    console.log('this.$route.path', this.$route.path)
    string = getLocalStorage('localSetMemory') || `{"modalitytype":"","depArea":"","areaName":"","dep":"","deps":[]}`
    logoutFlag = localStorage.getItem('logoutFlag')
    localSetMemoryObj = JSON.parse(string)
    this.isMpiOrPid = this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.mpi || window.g.isMpiOrPid
    this.tableColumns = this.getTableColumns()
    this.isShowTwoList = getIsShowTwoList()
    // 温州市中心医院门诊不走缓存不要删除！！
    this.isSetStorageAreaName = getIsSetStorageAreaName()
    this.kyCardReaderOptions = this.KYCARDREADER_OPTIONS || window.g.KYCARDREADER_OPTIONS || window.g.KYCARDREADER_OPTIONS_FUDING || rtUtil.defaultType
    // 是否默认勾选住院条件下的未登记
    if (this.isUnregistered) {
      this.formdata.unregistered = true
    }
    console.log(`getLocalStorage('yjyy-formMoreOpen')`, getLocalStorage('yjyy-formMoreOpen'))
    this.formMoreOpen = getLocalStorage('yjyy-formMoreOpen') || true
    this.refreshThisPatientSourceToQueryWay()
    if (window.g.jsonpRight) {
      if (!window.g.lcVERSION) {
        let newjs1 = window.sendJSONPRequest(window.g.APPOINT_URL + '/versionHandler.js', 'getLcVersion')
        newjs1.onload = () => {
          this.applyCheckUrl = this.getCheckUrl()
        }
      } else {
        this.applyCheckUrl = this.getCheckUrl()
      }
    } else {
      this.applyCheckUrl = this.getCheckUrl()
    }
    await this.gethospitalInfo(this.hospitalCode)
    // 获取缓存中的数据
    this.depAreaShow ? this.getDepAreaList() : null
    this.getAreaNameList()
    this.getTypeOptions()
    // this.queryWayOptions.forEach((item, index) => {
    //   if (item.label == '体检号' || item.label == '门诊号') {
    //     // item.label = '体检号、门诊号'
    //     this.queryWayOptions[index].label = '门诊/体检号'
    //   }
    // })
  },
  mounted() {
    // console.log('mounted=>this.notAutoSearchPatSource', this.notAutoSearchPatSource)
    // this.queryWayOptions = this.applyInfoHospital === 'wenfuer' ? this.queryWayChangeOptions : this.queryWayOptions
    this.operatorPatSourceOption(this.queryWayOptions)
    // console.warn('tableColumns', this.tableColumns)
    // 查询方式默认选择/初始化
    // patientSource: 1, // 病人类型 1-门诊 2-住院 3-体检 4-绿检 5-急诊 6-外院、0未知 默认0
    // queryWay: 2, // 查询方式 0-病人id 1-卡号 2-门诊号 3-住院号 4-发票号 5-申请单号 6-身份证号 7-社保卡号 暂时不用 8 手机号 默认0
    // this.formdata.queryWay = parseInt(getLocalStorage('queryWay')) ? parseInt(getLocalStorage('queryWay')) : window.g.IS_TRIGGER_PATIENTID ? 0 : !window.g.IS_TRIGGER_OUTPATIENT ? 1 : 2
    this.resetBtn()
    if (this.isHideApplyInfoBoxAndUseDialog && !this.hisTableHeight) {
      let formHeight = this.$refs.apply_form.clientHeight
      this.hisTableHeight = document.documentElement.clientHeight - formHeight - 148
      // setLocalStorage('yjyy-hisTableHeight', hisTableHeight)
    }
    if (this.hisTableHeight && this.hisTableHeight > 384) {
      if (!(window.g.applyHis && window.g.applyHis.isHideApplyInfoBoxAndUseDialog)) {
        this.hisTableHeight = 384
        setLocalStorage('yjyy-hisTableHeight', this.hisTableHeight)
      }
    }
    if (this.isShowWardNo) {
      this.getInpatientWard()
    }
    // 查询某个人的申请单后，左下方按钮从已预约列表切换到HIS申请的时候，被勾选的人继续发起联合预约
    // bus.$off('tabChangeToOne')
    // bus.$on('tabChangeToOne', () => {
    //   // // console.log('tabChangeToOne')
    //   this.timeout01 = setTimeout(() => {
    //     this.appointmentPostMessageUnion()
    //   }, 1000)
    // })
    // 检查预约登记页面与已预约列表之间的查询数据联动
    bus.$off('changeListData')
    bus.$on('changeListData', (res) => {
      if (res.type == 'patPriorityLevel') {
        this.changeListDataPatLevel(res.row, res.value, res.intValue)
      } else if (res.type == 'patientPhone') {
        this.changeListDataPhone(res.row, res.value)
      } else if (res.type == 'isOverBed') {
        this.setOverBed = res.value
        this.changeListDataBedSide(res.row, res.value)
        // this.appointmentPostMessage(res.row)  // 就是这句话造成了只改当前的，不适合用作医技时改数据，发送到临床预约
      } else if (res.type == 'patUpdateRemarkInfo') {
        this.changeListDataRemark(res.row, res.value, res.intValue)
      } else if (res.type == 'patPrivacyLevel') {
        this.changeListDataPatPrivacyLevel(res.row, res.value)
      } else if (res.type == 'hbsag') {
        this.changeHBsAg(res.row, res.value)
      } else if (res.type == 'hiv') {
        this.changeHIV(res.row, res.value)
      } else if (res.type == 'rpr') {
        this.changeRPR(res.row, res.value)
      } else if (res.type == 'hcv') {
        this.changeHCV(res.row, res.value)
      } else if (res.type == 'lisSerumGastric') {
        this.changePRG(res.row, res.value)
      } else if (res.type == 'creatinine') {
        this.changePRG(res.row, res.value)
      } else if (res.type == 'patModalityType') {
        this.changeModality(res.row, res.value)
      }
    })
    // 创建键盘模拟输入的事件监听
    this.$refs.WSCardReader.addInputEventListener('formQueryTextIpt', () => {
      return this.formdata.queryText.trim()
    })
    // 时时刷新判断
    if (getIsAutoRefresh() == true) {
      this.isAutoRefresh = true
    } else {
      this.isAutoRefresh = false
    }
    this.isAutoRefreshEvent()
  },
  beforeDestroy() {
    searchInterval && clearInterval(searchInterval)
    this.timeout01 && clearTimeout(this.timeout01)
    this.timeout02 && clearTimeout(this.timeout02)
    this.timeout03 && clearTimeout(this.timeout03)
    this.timeout04 && clearTimeout(this.timeout04)
    this.timeout05 && clearTimeout(this.timeout05)
    this.timeout06 && clearTimeout(this.timeout06)
    this.timeout07 && clearTimeout(this.timeout07)
    this.timeout08 && clearTimeout(this.timeout08)
    this.timeout09 && clearTimeout(this.timeout09)
    this.$store.dispatch('patient/setRowCurr', {})
    this.$store.dispatch('patient/setSelectedPatientInfo', {})
    // bus.$off('WSCardReader_msg_applyHIS')
    bus.$off('changeListData')
    bus.$off('tabChangeToOne')
  },
  methods: {
    // 刷卡返回结果的处理
    getWSCardReaderMsg(res) {
      if (res.searchText) {
        this.formdata.queryWay = getQueryWayByText(res.searchWay)
        this.formdata.queryText = res.searchText
        this.$nextTick(() => {
          this.search()
        }, 200)
      } else {
        this.formdata.queryText = ''
      }
    },
    // 关闭提示弹窗
    closeTipEvent() {
      this.dialogTipVisible = false
    },
    setCheckedInitStatus(_obj) {
      _obj.emergencylabel = this.getLevel(~~_obj.emergency)
      if (_obj.emergencylabel == 'VIP') {
        this.isVIP = true
      } else {
        this.isVIP = false
      }
      this.isVIP = Boolean((this.isVIP))
      _obj.isVIP = this.isVIP
      if (_obj.emergencylabel == '急诊') {
        this.isJZ = true
      } else {
        this.isJZ = false
      }
      this.isJZ = Boolean((this.isJZ))
      _obj.isJZ = this.isJZ
      return _obj
    },
    setTableConfig() {
      this.$refs.setTableConfig.dialogVisible = true
    },
    setTableCol() {
      this.configInfo = {}
      if (this.paramConfig) {
        if (this.paramConfig.hospitalParameterContent) {
          this.configInfo = this.paramConfig.hospitalParameterContent
          this.configInfo1 = JSON.parse(this.configInfo)
          if (this.configInfo1.checkHisTableColumnsConfig) {
            this.tableColumnTest = this.configInfo1.checkHisTableColumnsConfig
          }
        }
        if (this.paramConfig.userParameterContent) {
          this.configInfo = this.paramConfig.userParameterContent
          this.configInfo1 = JSON.parse(this.configInfo)
          if (this.configInfo1.hisTable) {
            this.tableColumnTest = this.configInfo1.hisTable
          }
        }
      }
      if (!this.tableColumnTest || Array.isArray(this.tableColumnTest) && this.tableColumnTest.length == 0) {
        this.tableColumnTest = Options.checkTableColumnsConfig
      }
      return this.tableColumnTest.filter(item => item.show)
    },
    appointTypeCheck(val) {
      if (val) {
        this.$emit('checkPostMsg', {
          type: 'changeAppointmentTypeConfig',
          isNoRowCurr: this.rowCurr === '',
          data: { typeConfig: '检查科室' }
        })
      } else if (!this.lcLoaded) {
        this.$emit('checkPostMsg', {
          type: 'changeAppointmentTypeConfig',
          isNoRowCurr: this.rowCurr === '',
          data: { typeConfig: this.appoint_type }
        })
      }
    },
    getTableColumns() {
      let _t = this.appConfig && this.appConfig.checkHisTableColumnsConfig ? this.appConfig.checkHisTableColumnsConfig : this.columnsConfig
      _t = this.setTableCol()
      _t.forEach(item => {
        if (item.prop == 'bedside' && item.show) {
          this.isConfigBedside = true
        }
      })
      return _t.filter(c => c.show).sort((a, b) => {
        return a.sort - b.sort
      })
    },
    operatorPatSourceOption(options) {
      let arr = options
      if (this.stestIDMergeOutID) {
        this.queryWayOptions.forEach((item, index) => {
          if (item.label == '门诊号') {
            this.queryWayOptions[index].label = '门诊/体检号'
          }
        })
      }
      if (this.tijianTotijianhao && this.formdata.patientSource == 3) {
        this.formdata.queryWay = 2 // 门诊号=>体检号
        for (let k in arr) {
          if (arr[k].name == '体检') {
            this.queryWayOptions.forEach((item, index) => {
              if (item.label == '门诊/体检号' || item.label == '门诊号') {
                this.queryWayOptions[index].label = '体检号'
              }
            })
          }
        }
      }
      if (this.formMoreOpen) {
        return arr
      } else if (this.appoint_pst) {
        return arr.filter(pso => this.appoint_pst.includes(pso.value))
      }
      return arr
    },
    isAutoRefreshEvent() {
      // console.warn('isAutoRefreshEvent=>进入实时刷新事件')
      searchInterval && clearInterval(searchInterval)
      if (this.isAutoRefresh == true) {
        this.formdata.dateRadio = '7'
        this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - 6 * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
        // 福鼎医院体检的申请单列表需要实实刷新
        // 列表刷新的时间间隔
        let applyListRefreshTime = (this.appConfig && this.appConfig.baseConfig && this.appConfig.baseConfig.applyListRefreshTime) || 10
        if (applyListRefreshTime >= 10) {
          searchInterval = setInterval(() => {
            if (this.formdata.patientSource == 3 && (this.hisActivedIndex == 3 || this.hisActivedIndex == 1)) {
              const beginTime = new Date(this.formdata.hisFormDate[0])
              const endTime = new Date(this.formdata.hisFormDate[1])
              // 计算时间戳差距
              const timeDiff = Math.abs(endTime.getTime() - beginTime.getTime())
              // 计算天数差距
              const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24))
              // // // console.log('daysDiff', daysDiff)
              if (daysDiff > 7) {
                this.formdata.dateRadio = '7'
                this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - 6 * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
              }
              this.getHisExamList()
            }
          }, applyListRefreshTime * 1000)
        }
      }
    },
    changeIsAutoRefresh(value) {
      // // // console.log('value', value)
      this.isAutoRefresh = value
      setIsAutoRefresh(value)
      // this.isAutoRefresh = value
      this.isAutoRefreshEvent()
    },
    resetBtn() {
      this.$store.dispatch('app/ISSMKBTNDISABLE', false)
      this.formdata.queryWay = this.IS_TRIGGER_PATIENTID ? 0 : parseInt(this.patientSourceToqueryWay[this.formdata.patientSource])
      this.formdata.queryText = ''
      this.formdata.patientName = ''
      // 打开页面的时候默认聚焦formQueryTextIpt输入框
      this.$nextTick(() => {
        this.$refs.formQueryTextIpt && this.$refs.formQueryTextIpt.focus()
      })
    },
    changeListDataBedSide(row, value, intValue) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          // console.log(`this.mix_tableData[${i}]`, this.mix_tableData[i])
          this.mix_tableData[i].bedside = value.isOverBed ? '床旁' : '非床旁'
          this.mix_tableData[i].isOverBed = value.isOverBed
          this.mix_tableData[i].extras = value.extras
        }
      }
    },
    changeListDataRemark(row, value, intValue) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId && this.mix_tableData[i].examItemName === row.examItemName) {
          // console.log(`this.mix_tableData[${i}]`, this.mix_tableData[i])
          this.mix_tableData[i].remarkInfo = value
        }
      }
    },
    changeListDataPatPrivacyLevel(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].PrivacyLevel = value
          this.mix_tableData[i].privacyLevel = value
        }
      }
    },
    changeHBsAg(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].hbsag = value
        }
      }
    },
    changeHIV(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].hiv = value
        }
      }
    },
    changeRPR(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].rpr = value
        }
      }
    },
    changeHCV(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].hcv = value
        }
      }
    },
    changePRG(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].lisSerumGastric = value
        }
      }
    },
    changeSCR(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].creatinine = value
        }
      }
    },
    changeModality(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].examClass = value
        }
      }
    },
    changeListDataPatLevel(row, value, intValue) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          // console.log(`this.mix_tableData[${i}]`, this.mix_tableData[i])
          this.mix_tableData[i].grade = value
          this.mix_tableData[i].emergencylabel = value
          this.mix_tableData[i].emergency = intValue
        }
      }
    },
    changeListDataPhone(row, value) {
      for (let i = 0; i < this.mix_tableData.length; i++) {
        if (this.mix_tableData[i].patientId === row.patientId) {
          this.mix_tableData[i].patientPhone = value
        }
      }
    },
    tiggerFormMoreOpen() {
      this.formMoreOpen = !this.formMoreOpen
      setLocalStorage('yjyy-formMoreOpen', this.formMoreOpen)
    },
    // refreshThisPatientSourceToQueryWay() {
    //   this.patientSourceToqueryWay = !window.g.IS_TRIGGER_OUTPATIENT ? JSON.parse(getLocalStorage('patientSourceToqueryWay')) || {
    //     1: 1, // 毕节的医院需求是门诊选到门诊号
    //     2: 2, // 毕节的医院需求是住院选到住院号
    //     3: 1,
    //     4: 1,
    //     5: 1,
    //     6: 1,
    //     0: 1
    //   } : { 1: 2, 2: 3, 3: 1, 4: 1, 5: 1, 6: 1, 0: 1 }
    // },
    close() {
      this.ddtvisible = false
    },
    detail(rowCurr) {
      let row = rowCurr
      row.emergencylabel = this.getLevel(rowCurr.emergency)
      // this.$store.dispatch('patient/setRowCurr', row)
      row = this.setCheckedInitStatus(row)
      this.setRowCurrEvent(row)
      this.ddtvisible = true
    },
    async getDepartment() {
      // 申请科室
      // let data = {
      //   HospitalCode: this.hospitalCode,
      //   type: '申请科室'
      // }
      // getItemListFunc(data).then(res => {
      //   this.departmentOptions = res.map(_item => _item.item)
      //   // // console.log('departmentOptions', this.departmentOptions)
      //   //  判断缓存中是否有JJYY_SET_TOKENINFO=>applyDepartment参数
      //   const tokenInfoString = localStorage.getItem('JJYY_SET_TOKENINFO')
      //   if (tokenInfoString && tokenInfoString.indexOf('applyDepartment') > -1) {
      //     const tokenInfo = JSON.parse(tokenInfoString)
      //     // console.warn('getItemListFunc=>tokenInfo', tokenInfo)
      //     if (tokenInfo.applyDepartment) {
      //       this.formdata.patientSource = 2
      //       this.formdata.applyDepartment = tokenInfo.applyDepartment || ''
      //       this.formdata.applyDepartmentCode = this.formdata.ApplyDepartmentCode = tokenInfo.applyDepartmentCode || tokenInfo.ApplyDepartmentCode || ''
      //       this.getFormDefaultLoaclStorage('set') // 'set'
      //     } else {
      //       this.formdata.applyDepartment = ''
      //       this.formdata.applyDepartmentCode = this.formdata.ApplyDepartmentCode = ''
      //     }
      //     if (tokenInfo.isCanSwitch == 1 || tokenInfo.isCanSwitch == 'true' || tokenInfo.isCanSwitch == undefined) {
      //       this.isDisabled = false
      //     } else {
      //       this.isDisabled = true
      //     }
      //   }
      // })
      let params = { HospitalCode: this.hospitalCode, type: '申请科室' }
      await this.$store.dispatch('settings/set_departmentOptions', params)
      // console.log('departmentOptions', this.departmentOptions)
      const tokenInfoString = localStorage.getItem('JJYY_SET_TOKENINFO')
      if (tokenInfoString && tokenInfoString.indexOf('applyDepartment') > -1) {
        const tokenInfo = JSON.parse(tokenInfoString)
        // console.warn('getItemListFunc=>tokenInfo', tokenInfo)
        if (tokenInfo.applyDepartment) {
          this.formdata.patientSource = 2
          this.formdata.applyDepartment = tokenInfo.applyDepartment || ''
          this.formdata.applyDepartmentCode = this.formdata.ApplyDepartmentCode = tokenInfo.applyDepartmentCode || tokenInfo.ApplyDepartmentCode || ''
          this.getFormDefaultLoaclStorage('set') // 'set'
        } else {
          this.formdata.applyDepartment = ''
          this.formdata.applyDepartmentCode = this.formdata.ApplyDepartmentCode = ''
        }
        if (tokenInfo.isCanSwitch == 1 || tokenInfo.isCanSwitch == 'true' || tokenInfo.isCanSwitch == undefined) {
          this.isDisabled = false
        } else {
          this.isDisabled = true
        }
      }
    },
    async getInpatientWard() {
      // 病区
      // let data = {
      //   HospitalCode: this.hospitalCode,
      //   type: '申请病区'
      // }
      // getItemListFunc(data).then(res => {
      //   this.inpatientWardOptions = res.map(_item => _item.item)
      //   // // console.log('this.inpatientWardOptions', this.inpatientWardOptions)
      // })
      if (!this.wardNoOptions.length) {
        let params = {
          HospitalCode: this.hospitalCode,
          type: '申请病区'
        }
        console.log('params', params)
        await this.$store.dispatch('settings/set_wardNoOptions', params)
      }
    },
    handleCheckAllChange(val) {
      this.mix_tableData.forEach(item => {
        if ((this.checkedPatId || (this.checkAll && (this.formdata.queryText.trim()) && this.formdata.queryWay !== 8 && this.formdata.queryWay !== 4)) &&
          (!this.isCheckExamStatus || (this.isCheckExamStatus && (item.examStatus === -1 || item.examStatus > 3)))
        ) {
          this.checkedPatId = item.patientId
          item.checked = val
        } else {
          item.checked = false
        }
      })
      if (!this.checkedPatId) {
        this.checkAll = false
      }
      if (!this.checkAll) {
        this.cancelCheckedChange()
      }
      this.isIndeterminate = false
    },
    checkallChange() {
      console.log('checkallChange=>')
      const checkedCount = this.mix_tableData.filter(item => item.checked).length
      const tableCheckList = this.mix_tableData.filter(item => !this.isCheckExamStatus || (this.isCheckExamStatus && (item.examStatus === -1 || item.examStatus > 3))).length
      this.checkAll = checkedCount === tableCheckList && checkedCount > 0
      this.isIndeterminate = checkedCount > 0 && checkedCount < tableCheckList
    },
    // appointTypeChange() {
    //   console.log('appointTypeChange=>this.appoint_type', this.appoint_type)
    //   // this.getFormDefaultLoaclStorage('set')
    //   // this.search()
    //   if (!this.lcLoaded) {
    //     // bus.$emit('appointmentChange', this.appoint_type)
    //     this.$emit('checkPostMsg', {
    //       type: 'changeAppointmentTypeConfig',
    //       isNoRowCurr: this.rowCurr === '',
    //       data: { typeConfig: this.appoint_type }
    //     })
    //   }
    //   this.set_appoint_type()
    // },
    async setAuthConfig() {
      // console.log('setAuthConfig')
      // console.log('this.isCloseHisAndConfigLink', this.isCloseHisAndConfigLink)
      let checkFormDefault = getLocalStorage(CHECK_FORM_DEFAULT_KEY) && JSON.parse(getLocalStorage(CHECK_FORM_DEFAULT_KEY)) || {}
      let localSetMemoryObj = JSON.parse((getLocalStorage('localSetMemory') || `{"modalitytype":"","depArea":"","areaName":"","dep":"","deps":[]}`))
      this.formdata.executeDepartMents = checkFormDefault.deps || []
      this.formdata.executeDepartMent = checkFormDefault.dep || ''
      this.collapseShow = this.formdata.executeDepartMents.length > 2
      if (!this.isCloseHisAndConfigLink) {
        // console.log('localSetMemoryObj.appointType', localSetMemoryObj.appointType)
        this.appoint_type = localSetMemoryObj.appointType ? localSetMemoryObj.appointType : (checkFormDefault && checkFormDefault.appoint_type ? checkFormDefault.appoint_type : this.appointTypeOptions.indexOf('前台登记') > -1 ? '前台登记' : this.appointTypeOptions[0])
        // console.log('this.appoint_type', this.appoint_type)
        // this.set_appoint_type()
      }
      // 中心医院患者类型还加了体检中心权限，权限代码YJYY1000809786，做个记录，对应预约来源为临床预约
      // 体检 YJYY1000809786
      // 门诊 YJYY1000809787
      // 住院 YJYY1000809788
      // 急诊 YJYY1000809789
      // 先判断患者类型中是否有体检，然后默认选中体检，然后设置为disabled
      // console.log('setAuthConfig=>this.patSourceOptions', this.patSourceOptions)
      if (this.$hasPermission(['YJYY1000809786'])) {
        const testResultIndex = this.patSourceOptions.findIndex(item => item.name == '体检')
        if (testResultIndex > -1) {
          this.formdata.patientSource = this.patSourceOptions[testResultIndex].value
          this.isDisabledByTest = true
        }
      } else if (this.$hasPermission(['YJYY1000809787'])) {
        const testResultIndex = this.patSourceOptions.findIndex(item => item.name == '门诊')
        if (testResultIndex > -1) {
          this.formdata.patientSource = this.patSourceOptions[testResultIndex].value
          this.isDisabledByTest = true
        }
      } else if (this.$hasPermission(['YJYY1000809788'])) {
        const testResultIndex = this.patSourceOptions.findIndex(item => item.name == '住院')
        if (testResultIndex > -1) {
          this.formdata.patientSource = this.patSourceOptions[testResultIndex].value
          this.isDisabledByTest = true
        }
      } else if (this.$hasPermission(['YJYY1000809789'])) {
        const testResultIndex = this.patSourceOptions.findIndex(item => item.name == '急诊')
        if (testResultIndex > -1) {
          this.formdata.patientSource = this.patSourceOptions[testResultIndex].value
          this.isDisabledByTest = true
        }
      }

      // 权限代码对应预约来源
      const appointKeyToName = {
        'YJYY1000809790': '移动预约',
        'YJYY1000809791': '外院预约',
        'YJYY1000809792': '自助预约',
        'YJYY1000809781': '临床预约',
        'YJYY1000809793': '前台登记',
        'YJYY1000809794': '联合预约',
        'YJYY1000809795': '转诊预约',
        'YJYY1000809782': '登记机房',
        'YJYY1000809783': '检查科室',
        'YJYY1000809785': '预约中心'
      }
      let appointTypeOptions = []
      // 把有权限的预约来源push到appointTypeOptions中
      Object.keys(appointKeyToName).forEach(key => {
        // const code = 'YJYY1000809786'
        if (this.$hasPermission([key])) {
          appointTypeOptions.push(appointKeyToName[key])
        }
      })
      console.log('appointTypeOptions=>', appointTypeOptions)
      if (appointTypeOptions.length) {
        // set_appointTypeOptionsOnly不走接口，直接赋值
        this.appointTypeOptions = appointTypeOptions
        // await this.$store.dispatch('settings/set_appointTypeOptionsOnly', appointTypeOptions)
        if (!isNull(checkFormDefault) && checkFormDefault.appoint_type) {
          let appoint_type = checkFormDefault.appoint_type // 这里应该优先取缓存，需要判断
          // 还有一种情况，localSetMemory里的缓存也有appointType值
          // 判断appoint_type是否在appointTypeOptions中，若在直接赋值，若不在则取列表中的第一个值
          console.log('appointTypeOptions.length=》appointTypeOptions', appointTypeOptions)
          if (appointTypeOptions.indexOf(appoint_type) > -1) {
            this.appoint_type = appoint_type
            console.log('this.appoint_type03', this.appoint_type)
          } else {
            this.appoint_type = appointTypeOptions[0] // 这里取列表中的第一个值
            console.log('this.appoint_type01', this.appoint_type)
          }
        } else {
          this.appoint_type = appointTypeOptions[0] // 这里取列表中的第一个值
          console.log('this.appoint_type02', this.appoint_type)
        }
      } else {
        console.log('=========>')
        // set_appointTypeOptions走接口
        // let params = { HospitalCode: this.$store.state.user.hospitalCode, type: '预约来源' }
        // await this.$store.dispatch('settings/set_appointTypeOptions', params)
        if (!this.isCloseHisAndConfigLink) {
          this.appoint_type = localSetMemoryObj.appointType ? localSetMemoryObj.appointType : (checkFormDefault && checkFormDefault.appoint_type ? checkFormDefault.appoint_type : this.appointTypeOptions.indexOf('前台登记') > -1 ? '前台登记' : this.appointTypeOptions[0])
        } else {
          this.appoint_type = this.appointTypeOptions.indexOf('前台登记') > -1 ? '前台登记' : this.appointTypeOptions[0]
        }
      }
      this.set_appoint_type()
    },
    async set_appoint_type() {
      // console.log('set_appoint_type', window.g.APPOINT_TYPE_OPTIONS)
      if (window.g.APPOINT_TYPE_OPTIONS && window.g.APPOINT_TYPE_OPTIONS.length) {
        let appointList = window.g.APPOINT_TYPE_OPTIONS
        this.appoint_type = appointList[0]
      }
      // console.log('this.isCloseHisAndConfigLink', this.isCloseHisAndConfigLink)
      // let checkFormDefault = JSON.parse(getLocalStorage(CHECK_FORM_DEFAULT_KEY))
      // let localSetMemoryObj = JSON.parse((getLocalStorage('localSetMemory') || `{"modalitytype":"","depArea":"","areaName":"","dep":"","deps":[]}`))
      // if (!this.isCloseHisAndConfigLink) {
      //   console.log('set_appoint_type=>localSetMemoryObj.appointType', localSetMemoryObj.appointType)
      //   if (this.appointTypeOptions.indexOf(localSetMemoryObj.appointType) > -1) {
      //     this.appoint_type = localSetMemoryObj.appointType ? localSetMemoryObj.appointType : (checkFormDefault && checkFormDefault.appoint_type ? checkFormDefault.appoint_type : this.appointTypeOptions.indexOf('前台登记') > -1 ? '前台登记' : this.appointTypeOptions[0])
      //   } else {
      //     console.log('来到这里了？', this.appoint_type)
      //     // this.appoint_type = this.appointTypeOptions.indexOf('前台登记') > -1 ? '前台登记' : this.appointTypeOptions[0]
      //   }
      // }
      let data = {
        depArea: this.formdata.depArea,
        areaName: this.formdata.areaName,
        modalitytype: this.formdata.modalitytype,
        deps: this.formdata.executeDepartMents,
        dep: this.formdata.executeDepartMent,
        appoint_type: this.appoint_type,
        dateRadio: this.formdata.dateRadio,
        patientSource: this.formdata.patientSource
      }
      const dataFormData = JSON.parse(JSON.stringify(data))
      setLocalStorage(CHECK_FORM_DEFAULT_KEY, JSON.stringify(dataFormData))
    },
    async getFormDefaultLoaclStorage(set, setPat) {
      // console.log('getFormDefaultLoaclStorage=>this.appoint_type', this.appoint_type)
      // console.error('set', set == 'set')
      let checkFormDefault = getLocalStorage(CHECK_FORM_DEFAULT_KEY) || `{"appoint_type":"前台登记","areaName":"","dateRadio":"7","dep":"","depArea":"","deps":[],"modalitytype":"","patientSource":1}`
      let areaName = JSON.parse(checkFormDefault) && JSON.parse(checkFormDefault) != null ? JSON.parse(checkFormDefault).areaName || '' : ''
      // console.log('本地缓存的配置', checkFormDefault)
      // 第一次配置
      if (!(set == 'set')) {
        // 如果用户权限配置了，则取用户权限里的值
        localSetMemoryObj = JSON.parse((getLocalStorage('localSetMemory') || `{"modalitytype":"","depArea":"","areaName":"","dep":"","deps":[]}`))
        // // console.log('localSetMemoryObj', localSetMemoryObj)
        if (localSetMemoryObj) {
          // 否则就取页面缓存的值
          // 院区
          if (this.isSetStorageAreaName && JSON.parse(checkFormDefault) && JSON.parse(checkFormDefault).patientSource == 1) {
            this.formdata.areaName = ''
          } else if (!this.isCloseHisAndConfigLink) {
            this.formdata.areaName = localSetMemoryObj.areaName || areaName || ''
          } else {
            if (checkFormDefault) {
              this.formdata.areaName = areaName || ''
            }
          }
          // this.formdata.areaName = localSetMemoryObj.areaName == '' && checkFormDefault ? JSON.parse(checkFormDefault).areaName : localSetMemoryObj.areaName
          // 影像院区
          if (!this.isCloseHisAndConfigLink) {
            this.formdata.depArea = localSetMemoryObj.depArea || (JSON.parse(checkFormDefault) && JSON.parse(checkFormDefault).depArea ? JSON.parse(checkFormDefault).depArea : '')
          } else {
            if (checkFormDefault) {
              this.formdata.depArea = JSON.parse(checkFormDefault).depArea || ''
            }
          }
          // this.formdata.depArea = localSetMemoryObj.depArea == '' && checkFormDefault ? JSON.parse(checkFormDefault).depArea : localSetMemoryObj.depArea
          // 部门
          if (!this.isCloseHisAndConfigLink) {
            this.isChooseDeps ? (this.formdata.executeDepartMents = localSetMemoryObj.deps || JSON.parse(checkFormDefault).deps) || [] : (this.formdata.executeDepartMent = localSetMemoryObj.dep || (JSON.parse(checkFormDefault) && JSON.parse(checkFormDefault).dep ? JSON.parse(checkFormDefault).dep : ''))
          } else {
            if (checkFormDefault) {
              this.isChooseDeps ? (this.formdata.executeDepartMents = JSON.parse(checkFormDefault).deps || []) : (this.formdata.executeDepartMent = JSON.parse(checkFormDefault).dep || '')
            }
          }
          // this.formdata.executeDepartMent = localSetMemoryObj.dep === '' && checkFormDefault ? (JSON.parse(checkFormDefault).dep || '') : (localSetMemoryObj.dep || '')
          // 设备
          if (!this.isCloseHisAndConfigLink) {
            // console.log('localSetMemoryObj.modalitytype', localSetMemoryObj.modalitytype)
            this.formdata.modalitytype = localSetMemoryObj.modalitytype || (JSON.parse(checkFormDefault) && JSON.parse(checkFormDefault).modalitytype ? JSON.parse(checkFormDefault).modalitytype : '')
          } else {
            if (checkFormDefault) {
              this.formdata.modalitytype = JSON.parse(checkFormDefault).modalitytype || ''
            }
          }
          // console.log('this.formdata.modalitytype', this.formdata.modalitytype)
          // this.formdata.modalitytype = localSetMemoryObj.modalitytype === '' && checkFormDefault ? JSON.parse(checkFormDefault).modalitytype : localSetMemoryObj.modalitytype
          // 预约来源需要权限控制，默认的时候，没权限的不能显示缓存里的配置 -- 开始
          if (window.g.appointSourceFlag) {
            let cfd = checkFormDefault && JSON.parse(checkFormDefault || {})
            var flag = false
            // // console.log('cfd', cfd)
            //  先判断缓存的预约来源，当前登录人预约来源权限有没有
            if (cfd && cfd.appoint_type && this.appointTypeOptions.indexOf(cfd.appoint_type) > -1) {
              flag = true
              if ((this.appointSourceNameList || ['自助预约', '移动预约']).includes(cfd.appoint_type) && !this.$hasPermission(['YJYY10008098'])) {
                flag = false
              }
            }
            if (!this.isCloseHisAndConfigLink && localSetMemoryObj && localSetMemoryObj.appointType && this.appointTypeOptions.indexOf(localSetMemoryObj.appointType) > -1) {
              flag = true
              if ((this.appointSourceNameList || ['自助预约', '移动预约']).includes(localSetMemoryObj.appointType) && !this.$hasPermission(['YJYY10008098'])) {
                flag = false
              }
            }
            // 缓存里面没有的话
            if (!flag) {
              if (this.appointTypeOptions.indexOf('前台登记') > -1) {
                this.appoint_type = '前台登记'
              } else if (this.appointTypeOptions.indexOf('临床预约') > -1) {
                this.appoint_type = '临床预约'
              }
            } else {
              // if (!this.isCloseHisAndConfigLink) {
              this.appoint_type = localSetMemoryObj.appointType || cfd.appoint_type || '前台登记'
            }
          } else {
            // if (!this.isCloseHisAndConfigLink) {
            let appointType = checkFormDefault && JSON.parse(checkFormDefault).appoint_type ? JSON.parse(checkFormDefault).appoint_type : this.appoint_type
            this.appoint_type = localSetMemoryObj.appointType || appointType || '前台登记'
          }
          // 预约来源需要权限控制，默认的时候，没权限的不能显示缓存里的配置 -- 结束
          this.formdata.patientSource = checkFormDefault && JSON.parse(checkFormDefault).patientSource ? JSON.parse(checkFormDefault).patientSource : this.formdata.patientSource
          if (checkFormDefault && JSON.parse(checkFormDefault).dateRadio) {
            this.formdata.dateRadio = JSON.parse(checkFormDefault).dateRadio
            this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - Math.abs(~~JSON.parse(checkFormDefault).dateRadio - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
          }
          this.getDepList()
        } else if (setPat == 'setPatSource') {
          // 第二次配置
          let data = {
            depArea: this.formdata.depArea,
            areaName: this.formdata.areaName,
            modalitytype: this.formdata.modalitytype,
            deps: this.formdata.executeDepartMents,
            dep: this.formdata.executeDepartMent,
            appoint_type: this.appoint_type,
            dateRadio: this.formdata.dateRadio,
            patientSource: this.formdata.patientSource
          }
          const dataFormData = JSON.parse(JSON.stringify(data))
          dataFormData.areaName = this.isSetStorageAreaName && this.formdata.patientSource == 1 ? areaName : this.formdata.areaName
          this.getDepList()
          setLocalStorage(CHECK_FORM_DEFAULT_KEY, JSON.stringify(dataFormData))
          this.formdata.areaName = this.isSetStorageAreaName && this.formdata.patientSource == 1 ? '' : areaName
        } else {
          // 第二次配置
          this.formdata.depArea = checkFormDefault && JSON.parse(checkFormDefault).depArea ? JSON.parse(checkFormDefault).depArea : this.formdata.depArea
          this.formdata.areaName = checkFormDefault && JSON.parse(checkFormDefault).areaName ? JSON.parse(checkFormDefault).areaName : this.formdata.areaName
          this.formdata.modalityType = checkFormDefault && JSON.parse(checkFormDefault).modalitytype ? JSON.parse(checkFormDefault).modalitytype : this.formdata.modalitytype
          this.formdata.executeDepartMent = checkFormDefault && JSON.parse(checkFormDefault).dep ? JSON.parse(checkFormDefault).dep : this.formdata.executeDepartMent
          this.formdata.executeDepartMents = checkFormDefault && JSON.parse(checkFormDefault).deps ? JSON.parse(checkFormDefault).deps : this.formdata.executeDepartMents
          this.appoint_type = checkFormDefault && JSON.parse(checkFormDefault).appoint_type ? JSON.parse(checkFormDefault).appoint_type : this.appoint_type
          this.formdata.patientSource = checkFormDefault && JSON.parse(checkFormDefault).patientSource ? JSON.parse(checkFormDefault).patientSource : this.formdata.patientSource
          if (checkFormDefault && JSON.parse(checkFormDefault).dateRadio) {
            this.formdata.dateRadio = JSON.parse(checkFormDefault).dateRadio
            this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - Math.abs(~~JSON.parse(checkFormDefault).dateRadio - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
          }
          const dataFormData = JSON.parse(JSON.stringify(this.formdata))
          dataFormData.areaName = this.isSetStorageAreaName && this.formdata.patientSource == 1 ? areaName : this.formdata.areaName
          this.getDepList()
          setLocalStorage(CHECK_FORM_DEFAULT_KEY, JSON.stringify(this.formdata))
        }
      } else {
        // 第二次配置
        let data = {
          depArea: this.formdata.depArea,
          areaName: this.formdata.areaName,
          modalitytype: this.formdata.modalitytype,
          deps: this.formdata.executeDepartMents,
          dep: this.formdata.executeDepartMent,
          appoint_type: this.appoint_type,
          dateRadio: this.formdata.dateRadio,
          patientSource: this.formdata.patientSource
        }
        const dataFormData = JSON.parse(JSON.stringify(data))
        dataFormData.areaName = this.isSetStorageAreaName && this.formdata.patientSource == 1 ? areaName : this.formdata.areaName
        setLocalStorage(CHECK_FORM_DEFAULT_KEY, JSON.stringify(dataFormData))
      }
      if (this.applyInfoHospital === 'wzszxyy' || this.hospitalCode === '47052555733030211A1001') {
        if (this.formdata.patientSource === 3 && this.tijianTotijianhao) {
          this.formdata.queryWay = 2
        } else {
          let queryWayDefault = getLocalStorage('patientSourceToqueryWay') || {}
          console.log('querywatDefualt', queryWayDefault)
          console.log('isNull(123)', isNull(123))
          this.formdata.queryWay = !isNull(queryWayDefault) && JSON.parse(queryWayDefault)[this.formdata.patientSource] || this.formdata.queryWay
        }
      }
      this.formdata.depArea = this.depAreaShow ? this.formdata.depArea : ''
      this.formdata.areaName = this.areaNameShow ? this.formdata.areaName : ''
      this.setAuthConfig()
    },
    // 获取影像区域列表
    async getDepAreaList() {
      if (this.depAreaOptions.length === 0) {
        let params = { HospitalCode: this.hospitalCode, areaName: this.formdata.areaName }
        await this.$store.dispatch('settings/set_depAreaOptions', params)
      }
    },
    // 获取院区列表
    async getAreaNameList() {
      // const params = {
      //   HospitalCode: this.hospitalCode
      // }
      // getListByAreaNameFunc(params).then(res => {
      //   this.areaNameOptions = res
      // })
      if (this.areaNameOptions.length === 0) {
        let params = { HospitalCode: this.hospitalCode }
        await this.$store.dispatch('settings/set_areaNameOptions', params)
      }
    },
    // 获取设备类型
    getModalityTypeList() {
      const params = {
        HospitalCode: this.hospitalCode,
        dep: this.isChooseDeps ? this.formdata.executeDepartMents : this.formdata.executeDepartMent
      }
      getModalityTypeListFunc(params).then(res => {
        this.modalitytypeOptions = res
        // if (this.modalitytypeOptions.indexOf(this.formdata.modalitytype) === -1) {
        //   this.formdata.modalitytype = ''
        // }
        // console.log('this.formdata.modalitytype', this.formdata.modalitytype)
      })
    },
    depAreaChange() {
      // // console.log('depAreaChange', this.formdata.depArea)
      let params = {
        depArea: this.formdata.depArea
      }
      setHISRecordDialogMemory(params)
      this.cancelCheckedChange()
      // console.log('depAreaChange')
      this.filterList()
      this.getFormDefaultLoaclStorage('set')
    },
    // 切换院区
    areaNameChange() {
      this.loading = true
      this.cancelCheckedChange()
      // 联动有点复杂 先全清了
      this.formdata.depArea = ''
      // // console.log('areaNameChange')
      this.filterList()
      this.getFormDefaultLoaclStorage('set', 'areaNameChange') // 清理之前，就先保存好当前选择的记录。
      this.depAreaShow ? this.getDepAreaList() : null
    },
    modalitytypeChange(val) {
      this.loading = true
      // // console.log('modalitytypeChange')
      this.filterList()
      this.cancelCheckedChange()
      setLocalStorage('yjyy@modalitytype', val)
      this.getFormDefaultLoaclStorage('set')
    },
    filterList() {
      let dlist = JSON.parse(JSON.stringify(this.tableDataShowAll))
      // console.log('filterList=>dlist.len=>', dlist.length)
      window.formdata = this.formdata
      let string = ''
      // 影像区域过滤
      if (this.depAreaShow && this.formdata.depArea) {
        string += 'tl.organizationNo === window.formdata.depArea ) && ('
      }
      if (this.areaNameShow && this.formdata.areaName) {
        string += 'tl.organizationNo === window.formdata.areaName ) && ('
      }
      if (this.modalitytypeShow && this.formdata.modalitytype) {
        string += 'tl.examClass === window.formdata.modalitytype ) && ('
      }
      // 检查部门
      if (!this.isChooseDeps && this.formdata.executeDepartMent) { // examExecuteDepartment
        string += 'tl.dep === window.formdata.executeDepartMent ) && ('
      }
      if (this.isChooseDeps && this.formdata.executeDepartMents) { // examExecuteDepartments
        string += 'window.formdata.executeDepartMents.includes(tl.dep) || window.formdata.executeDepartMents.length === 0 ) && ('
      }
      // 执行科室过滤 不用前端过滤，在请求国密的接口 (此处是申请科室)
      if (this.isShowApplyDepart && this.formdata.applyDepartment) {
        string += 'tl.applyDepartment === window.formdata.applyDepartment ) && ('
      }
      // 病区
      if (this.isShowWardNo && this.formdata.wardNo) {
        string += 'tl.wardNo === window.formdata.wardNo ) && ('
      }
      // 已取消过滤
      if (this.cancelShow && this.formdata.cancel) {
        string += 'tl.examStatus !== 4 ) && ('
      }
      // 只住院的查询过滤 原始(未登记)，已作废(已退单)
      // 旧写法 if (this.formdata.patientSource === 2 && this.formdata.unregistered && this.returnedShow && !this.checkedPatId) {
      if (this.formdata.patientSource === 2 && this.formdata.unregistered && this.unregisteredSHow && (this.applyInfoHospital === 'wzszxyy' || !this.checkedPatId || this.hospitalCode === '47052555733030211A1001')) {
        // 未登记的过滤，需要列表没有选择数据时才过滤
        // 未登记
        string += 'tl.examStatus === 5 ) && ('
      }
      if (this.formdata.patientSource === 2 && this.formdata.returned && this.returnedShow) {
        // 已退单
        string += 'tl.examStatus === 4 ) && ('
      }
      if (this.formdata.patientName) {
        // 姓名过滤
        string += 'tl.patientName.indexOf((window.formdata.patientName || \'\').trim()) > -1 ) && ('
      }
      if (this.formdata.bedside) {
        // 住院的病人过滤床旁
        string += 'tl.isBed ) && ('
      }
      // if (this.formdata.hisFormDate) {
      //   // 日期过滤
      //   const beginTime = new Date(this.formdata.hisFormDate[0])
      //   const endTime = new Date(this.formdata.hisFormDate[1])
      //   string = 'tl => new Date(tl.applyDateTime) >=' + beginTime + '&& new Date(tl.applyDateTime) <=' + endTime + '+) && ('
      // }
      this.timeout02 = setTimeout(() => {
        this.loading = false
      }, 800)
      if (string) {
        let intFlag = string.lastIndexOf(' && (')
        string = string.substring(0, intFlag)
        string = 'if((' + string + '){ return true }'
        console.log('filter->string', string)
        let fun = new Function('tl', string)
        dlist = dlist.filter(tl => !!fun(tl))
        // console.warn('dlist=>2-filter', dlist.length)
      }
      if (this.applyDepartmentCodeFilterArr && this.applyDepartmentCodeFilterArr.length) {
        dlist = dlist.filter(item => !this.applyDepartmentCodeFilterArr.split('-').includes(item.applyDepartmentCode))
      }
      this.vt_init(dlist)
      if (this.mix_tableData.length <= 0) {
        // 如果是查询某个人的时候，再去跳转到已预约列表
        if (this.formdata.queryText || this.formdata.patientName) {
          let newRow = this.setRowCurrEvent(this.formdata)
          this.$store.commit('patient/SELECTEDPATIENTINFO', newRow)
          this.$store.dispatch('patient/setHisActivedIndex', 3)
          this.$parent.$parent.btnTypeChange(3)
          this.$nextTick(() => {
            console.log('查看这里selectedRowCurr', this.formdata)
            bus.$emit('selectedRowCurr', this.formdata)
          }, 200)
        }
      } else {
        this.$nextTick(() => {
          // 先切换或显示已预约列表页面, 通过姓名或者卡号等搜索的时候，若有搜索到数据，就默认选中第一条申请单
          // 第一条申请单需要是选中的状态的数据
          let checkMixTable = window.g.IS_TRIGGER_HISCHECK ? this.mix_tableData : this.mix_tableData.filter((item) => item.checked)
          let newData = Object.assign({}, checkMixTable[0])
          // 如果当前选中的申请单和第一条申请单不一样，但是是同一个人的，就要被覆盖掉
          if (this.rowCurr.applyCode && this.rowCurr.checked && (this.rowCurr.patientName == newData.patientName || this.rowCurr.mpi == newData.mpi || this.rowCurr.patientId == newData.patientId)) {
            newData = JSON.parse(JSON.stringify(this.rowCurr))
          }
          // 通过姓名或者卡号等搜索的时候，若有搜索到数据
          if ((this.formdata.queryText.trim() || this.formdata.patientName.trim())) {
            this.setRowCurrEvent(newData)
          }
        }, 300)
        // mix_tableData 判断是否有病区和床号
        this.tableColumns.forEach(item => {
          if (item.prop == 'wardNo') {
            let wardNoIsNull = true
            // this.mix_tableData.forEach(obj => {
            //   if (!isNull(obj['wardNo'])) {
            //     wardNoIsNull = false
            //   }
            // })
            for (let i = 0; i < this.mix_tableData.length - 1; i++) {
              if (!isNull(this.mix_tableData[i]['wardNo'])) {
                wardNoIsNull = false
                break
              }
            }
            // 如果病区都为空，删除tableColumns中的病区字段
            if (wardNoIsNull) {
              const wardNoIndex = this.tableColumns.findIndex(item => item.prop == 'wardNo')
              // console.log('wardNoIndex', wardNoIndex)
              this.tableColumns.splice(wardNoIndex, 1)
              // console.log('this.tableColumns', this.tableColumns)
            }
          }
          if (item.prop == 'bedNo') {
            let bedNoIsNull = true
            // this.mix_tableData.forEach(obj => {
            //   if (!isNull(obj['bedNo'])) {
            //     bedNoIsNull = false
            //   }
            // })
            for (let i = 0; i < this.mix_tableData.length - 1; i++) {
              if (!isNull(this.mix_tableData[i]['bedNo'])) {
                bedNoIsNull = false
                break
              }
            }
            // 如果床号都为空，删除tableColumns中的床号字段
            if (bedNoIsNull) {
              const bedNoIndex = this.tableColumns.findIndex(item => item.prop == 'bedNo')
              // console.log('bedNoIndex', bedNoIndex)
              this.tableColumns.splice(bedNoIndex, 1)
              // console.log('this.tableColumns', this.tableColumns)
            }
          }
        })
      }
      // dlist = null
    },
    filterInit() {
      this.handleInit()
      this.applyCheckUrl = ''
      this.timeout03 = setTimeout(() => {
        this.applyCheckUrl = this.getCheckUrl()
      }, 200)
    },
    getCheckUrl() {
      this.lcLoaded = false
      let strType = this.formdata.fromCheckDepartment ? '检查科室' : (this.appoint_type || '')
      let string = this.appoint_url + `&v=${window.g.lcVERSION || window.g.VERSION}&yeFlag=1&hospitalCode=${this.hospitalCode}&hospitalName=${this.hospitalName}&operateUser=${this.userName}&operateCode=${this.userCode}&appointmentType2=${strType}&appointmentType=${strType}`
      let registerRoom = getLocalStorage('UserPermision') || ''
      if (registerRoom) {
        string += '&registerRoom=' + registerRoom
      }
      string += '&patientId='
      // console.log('getCheckUrl=>string', string)
      return string
    },
    appointTypeChange() {
      console.log('appointTypeChange=>this.appoint_type', this.appoint_type)
      this.set_appoint_type()
      if (!this.lcLoaded) {
        // bus.$emit('appointmentChange', this.appoint_type)
        this.$emit('checkPostMsg', {
          type: 'changeAppointmentTypeConfig',
          isNoRowCurr: this.rowCurr === '',
          data: { typeConfig: this.appoint_type }
        })
      }
      // 就这样写 别改bus 了 更容易出问题
      if (this.$parent.$parent.btnActive == 3) {
        this.$nextTick(() => {
          this.$parent.$parent.$refs.AppointedHISListRef && (this.$parent.$parent.$refs.AppointedHISListRef.appoint_type = this.appoint_type)
        })
      }
    },
    async getTypeOptions() {
      // 如果在配置文件配置，则不在数据字段获取
      if (window.g.APPOINT_TYPE_OPTIONS) {
        if (window.g.APPOINT_TYPE_OPTIONS.length) {
          let appointList = window.g.APPOINT_TYPE_OPTIONS
          this.appoint_type = appointList[0]
        }
        return
      }
      // 这里只能单独查询，不然改约的时候预约来源的权限将会出现无法控制住的bug（福鼎市医院)
      let params = { HospitalCode: this.hospitalCode, type: '预约来源' }
      // await this.$store.dispatch('settings/set_appointTypeOptions', params)
      getItemList(params).then(res => {
        if (res.code === 10000) {
          let list = res.content.list || []
          this.appointTypeOptions = list.map(_item => _item.item).filter(ap => ap)
          // this.getFormDefaultLoaclStorage()
        }
      }).finally(() => {
        this.getFormDefaultLoaclStorage()
        // this.setAuthConfig()
      })
    },
    dateRadioChange() {
      // // console.log('this.formdata.dateRadio', this.formdata.dateRadio)
      if (this.formdata.dateRadio) {
        this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - Math.abs(~~this.formdata.dateRadio - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
        this.isFocusRadio = true
        this.getFormDefaultLoaclStorage('set')
        this.search()
      }
    },
    hisFormDateChange() {
      const d1 = this.formdata.hisFormDate[0]
      const d2 = this.formdata.hisFormDate[1]
      console.log('d1', d1)
      console.log('d2', d2)
      console.log('nowDate', new Date())
      this.formdata.hisFormDate = [getDateYMD(new Date(d1).getTime()), getDateYMD(new Date(d2).getTime())]
      // // console.log('this.formdata.hisFormDate', this.formdata.hisFormDate)
      setLocalStorage('jjyy-lastDateRadio', this.formdata.dateRadio)
      this.formdata.dateRadio = ''
      let dd = diffDay(d1, d2) + 1
      // console.log('dd', dd)
      if ((dd == 1 || dd == 3 || dd == 7 || dd == 30) && getDateYMD(d2) == getDateYMD(new Date())) {
        this.formdata.dateRadio = dd + ''
      } else {
        this.formdata.dateRadio = ''
      }
      setLocalStorage(CHECK_FORM_DEFAULT_KEY, JSON.stringify(this.formdata))
      // this.getFormDefaultLoaclStorage('set')
      this.isFocusRadio = true
      this.isToSearch = true
      this.search()
    },
    isCanSearch() {
      // 如果时间大于30天需要把光标移到刷卡部分的输入框，并且给与提示不让查询
      if (this.formdata.hisFormDate) {
        // 先去把缓存中的dateRadio时间赋值给hisFormDate，这步是对于先通过卡号等条件查询某个人后，再清空卡号重新查询所有人的时候，时间交互逻辑的优化
        if (!this.isFocusRadio) {
          // 这里有问题
          let checkFormDefault = getLocalStorage(CHECK_FORM_DEFAULT_KEY)
          this.formdata.dateRadio = checkFormDefault ? JSON.parse(checkFormDefault).dateRadio : '7'
          let day = ~~this.formdata.dateRadio
          // // console.log('是不是到这里了day', day)
          if (day > 0) {
            this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - Math.abs(day - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
            // // console.log('this.formdata.hisFormDate', this.formdata.hisFormDate)
          }
        }
        // // console.log('this.formdata.hisFormDate=>', this.formdata.hisFormDate)
        // 日期过滤
        const beginTime = new Date(this.formdata.hisFormDate[0] + ' 00:00:01')
        const endTime = new Date(this.formdata.hisFormDate[1] + ' 23:59:59')
        // // console.log('beginTime', beginTime)
        // // console.log('endTime', endTime)
        // 计算时间戳差距
        const timeDiff = Math.abs(endTime.getTime() - beginTime.getTime())
        // // console.log('timeDiff', timeDiff)
        // 计算天数差距
        const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24))
        // // console.log('daysDiff', daysDiff)
        const patientName = (this.formdata.patientName && (this.formdata.patientName).trim()) || ''
        const queryText = (this.formdata.queryText && (this.formdata.queryText).trim()) || ''
        // 判断差距是否大于30天
        // // console.log('到这里了')
        // if (daysDiff != 1)
        let isEqual = false
        // let isEqualDay = ''
        this.dateRadioOptions.forEach(item => {
          // // console.log('item.value', item.value)
          // // console.log('daysDiff', daysDiff)
          if (item.value == daysDiff) {
            isEqual = true
            // isEqualDay = daysDiff
          }
        })
        // // console.log('isEqual', isEqual)
        if (isEqual == false) {
          this.formdata.dateRadio = ''
        } else {
          // this.formdata.dateRadio = daysDiff.toString() // 这行应该放开
        }
        // if (window.g.applyInfoHospital == 'fuding') {
        //   this.getFormDefaultLoaclStorage() // 'set'
        // }
        if (daysDiff > 30) {
          // // console.log('into daysDiff > 30')
          if (patientName.length || queryText.length) {
            return true
          } else {
            // let checkFormDefault = getLocalStorage(CHECK_FORM_DEFAULT_KEY)
            // this.formdata.dateRadio = ''
            // let checkFormDefault = getLocalStorage(CHECK_FORM_DEFAULT_KEY)
            // this.formdata.dateRadio = JSON.parse(checkFormDefault).dateRadio
            // let day = ~~this.formdata.dateRadio
            // // // console.log('day', day)
            // if (day > 0) {
            //   this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - day * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
            // }
            this.$message.warning('查询全部申请单的时候，为避免查询速度慢，时间范围不宜超过30天')
            const lastRadio = getLocalStorage('jjyy-lastDateRadio')
            if (!isNull(lastRadio)) {
              this.formdata.dateRadio = lastRadio + ''
            } else {
              this.formdata.dateRadio = '30'
            }
            let day = ~~this.formdata.dateRadio
            // // console.log('day', day)
            if (day > 0) {
              this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - (day - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
            }
            this.isToSearch = true
            this.$nextTick(() => {
              this.$refs.formQueryTextIpt && this.$refs.formQueryTextIpt.focus()
            }, 100)
            return true
          }
        } else {
          return true
        }
      } else {
        return true
      }
    },
    tableRowClassName({ row, rowIndex }) {
      let cls = ''
      if (row.dep == '内窥镜' && (this.applyInfoHospital == 'wenfuer' || this.hospitalCode == '47000593033030211A1001')) {
        // 签到过的状态要绿色的
        if (row.examClass.indexOf('无痛') > -1) {
          cls = 'blue-font'
        } else if (row.examClass.indexOf('磁控') > -1) {
          cls = 'blue-row'
        } else if (row.examClass.indexOf('支气管镜') > -1) {
          cls = 'yellow-row'
        } else if (row.examClass.indexOf('超声内镜') > -1) {
          cls = 'red-row'
        } else if (row.examClass.indexOf('外科肠镜') > -1) {
          cls = 'purple-row'
        } else if (row.examClass.indexOf('ERCP') > -1 && row.examText && row.examText.indexOf('鼻胆管') > -1) {
          cls = 'lightgreen-row'
        } else {
          cls = ''
        }
      } else {
        cls = ''
      }
      if (this.selectRowIds.includes(row.applyCode)) {
        cls += ' select-row '
      }
      // if (row.emergency > 0) {
      //   // 除了普通的，都标红色，已在配置项里设置，这里标识去除
      //   cls += 'danger-row '
      // }
      return cls
    },
    textUnderLine({ row, rowIndex }) {
      let cls = ''
      if (this.isLineThrough && !row.feeStatus) {
        cls += 'text-underline'
      }
      return cls
    },
    // 设置列表颜色
    tableRowStyle({ row, rowIndex }) {
      // 患者类型
      const checkPatTypeTable = this.patientTypeItemOptions // this.appConfig ? this.appConfig.checkPatTypeTable : Options.patientTypeItemOptions
      // 标志类型
      const checkTableConfig = this.appConfig ? this.appConfig.checkHisTable : this.emergencyTypes // this.appConfig ? this.appConfig.checkHisTable : Options.emergencyOptions
      let bgColor = ''
      let color = ''
      let colorFlag = 0
      if (row.emergency > 0) {
        if (checkTableConfig && colorFlag === 0) {
          const cObj = checkTableConfig.find(ctc => (ctc.name || ctc.label) == this.getEmergencyTip(row.emergency))
          if (cObj && cObj.colorStatus) {
            bgColor = cObj.bgColor
            color = cObj.fontColor
          }
        }
        let colorItem = {
          'background-color': bgColor,
          color
        }
        return colorItem
      }
      if (checkPatTypeTable && colorFlag === 0) {
        const cObj = checkPatTypeTable.find(ctc => ctc.value === row.patientSource)
        if (cObj && cObj.colorStatus) {
          bgColor = cObj.bgColor
          color = cObj.fontColor
          colorFlag = 1
        }
      }
      // if (!checkPatTypeTable && !checkTableConfig && row.emergency > 0 && color === '' && colorFlag === 0) {
      //   color = '#f00'
      // }
      const sObj = {
        'background-color': bgColor,
        color
      }
      return sObj
    },
    showPatInfo(row) {
      // // // // console.log('showPatInfo', row)
    },
    async gethospitalInfo(hospitalCode) {
      await getSysHospitalGetModelByCode({ hospitalCode }).then(res => {
        // console.log('---------------2')
        this.pubcliKey = res.content.guomiKey
        this.privateKey = res.content.guomiPrivateKey
        if (!window.g.API_ROOT_SCHEDULE) {
          window.g.API_ROOT_SCHEDULE = res.content.hiswebservice
        }
        // 对患者来源不进来就自动查询的判断
        if (!this.notAutoSearchPatSource || !this.notAutoSearchPatSource.includes(this.formdata.patientSource)) {
          // 患者类型是否默认为全部
          if (this.hisIsSelectAll) {
            this.formdata.patientSource = 0
            this.getFormDefaultLoaclStorage('set')
            // console.log('created=>this.formdata.patientSource', this.formdata.patientSource)
          }
          this.search()
        }
      })
      console.log('this.isShowApplyDepart', this.isShowApplyDepart)
      if (this.isShowApplyDepart) {
        console.log('---------------3')
        this.getDepartment()
        // console.log('---------------4')
      }
    },
    async getDepList(hospitalCode) {
      const params = {
        HospitalCode: this.hospitalCode
      }
      return new Promise(async resolve => {
        getDepList(params).then(res => {
          this.depOptions = res.content.list
          if (this.depOptions.indexOf(this.formdata.executeDepartMent) === -1) {
            this.formdata.executeDepartMent = ''
          }
          if (!(this.depOptions && this.formdata && this.depOptions.some(element => this.formdata.executeDepartMents.includes(element)))) {
            this.formdata.executeDepartMents = []
          }
          this.getModalityTypeList()
        })
        resolve()
      })
    },
    setPatientSourceToqueryWay() {
      this.patientSourceToqueryWay[this.formdata.patientSource || 0] = this.formdata.queryWay || 0
      setLocalStorage('patientSourceToqueryWay', JSON.stringify(this.patientSourceToqueryWay))
    },
    patSourceChange() {
      // console.log('this.formdata.patientSource', this.formdata.patientSource)
      // const resultIndex = this.notAutoSearchPatSource.indexOf(this.formdata.patientSource)
      // console.log('resultIndex', resultIndex)
      if (this.formdata.patientSource != 2) {
        this.isShowDayTag = false
      }
      if (this.stestIDMergeOutID) {
        this.queryWayOptions.forEach((item, index) => {
          if (item.label == '门诊号' || item.label == '体检号') {
            this.queryWayOptions[index].label = '门诊/体检号'
          }
        })
      }
      if (this.tijianTotijianhao && this.formdata.patientSource == 3) {
        this.queryWayOptions.forEach((item, index) => {
          if (item.label == '门诊号' || item.label == '门诊/体检号') {
            this.queryWayOptions[index].label = '体检号'
          }
        })
      }
      this.$nextTick(() => {
        this.$refs.formQueryTextIpt && this.$refs.formQueryTextIpt.focus()
      }, 100)
      // // // console.log('formdata.patientSource', this.formdata.patientSource)
      // patientSource: 1, // 病人类型 1-门诊 2-住院 3-体检 4 绿检 5急诊 6外院、0未知 默认0
      // queryWay: 2, // 查询方式 0-病人id 1-卡号 2-门诊号 3-住院号 4-发票号 5-申请单号 6-身份证号 7 社保卡号 暂时不用 8 手机号 默认0
      if (this.IS_TRIGGER_PATIENTID) {
        this.formdata.queryWay = 0
      } else {
        this.refreshThisPatientSourceToQueryWay()
        this.formdata.queryWay = this.patientSourceToqueryWay[this.formdata.patientSource]
      }
      if (this.formdata.patientSource == 1 && (this.applyInfoHospital == 'wzszxyy' || this.hospitalCode == '47052555733030211A1001')) {
        this.formdata.queryWay = 2
      }
      if (this.tijianTotijianhao && this.formdata.patientSource == 3) {
        this.formdata.queryWay = 2
      }
      this.formdata.bedside = false
      // this.isClearQueryText ? null : this.formdata.queryText = ''
      if (!this.isClearQueryText) {
        this.formdata.queryText = ''
        this.formdata.patientName = ''
      }
      if (this.isSetStorageAreaName) {
        let checkFormDefaultAreaName = getLocalStorage(CHECK_FORM_DEFAULT_KEY) ? JSON.parse(getLocalStorage(CHECK_FORM_DEFAULT_KEY)).areaName : ''
        let localSetMemoryObj = JSON.parse((getLocalStorage('localSetMemory') || `{"modalitytype":"","depArea":"","areaName":"","dep":""}`))
        this.formdata.areaName = this.isSetStorageAreaName && this.formdata.patientSource == 1 ? '' : (localSetMemoryObj && localSetMemoryObj.areaName ? localSetMemoryObj.areaName : checkFormDefaultAreaName)
        this.getFormDefaultLoaclStorage('set', 'setPatSource')
      } else {
        this.getFormDefaultLoaclStorage('set')
      }
      if (!this.notAutoSearchPatSource || !this.notAutoSearchPatSource.includes(this.formdata.patientSource)) {
        // console.log('patSourceChange=>search()')
        this.search()
      } else {
        // this.listInit()
        this.tableDataAll = []
        this.tableDataShowAll = this.tableDataAll
        this.filterList()
      }
    },
    getApplyData() {
      const fd = this.formdata
      const params = {
        patient: {
          patientId: fd.patientId, // 病人id
          masterPatientIndexId: fd.masterPatientIndexId, // 主索引
          idCard: fd.idCard, // 身份证
          ssnCardNo: fd.ssnCardNo, // 社保卡
          patientName: fd.patientName, // 姓名
          birthDate: fd.birthDate, // 出生日期
          gender: fd.gender, // 性别 值域：0-未知的性别；1-男性；2-女；9-未说明的性别
          address: fd.address, // 联系地址
          patientPhone: fd.patientPhone, // 联系电话
          organizationCode: fd.organizationCode// 档案所属机构
        },
        visit: {
          visitNo: fd.visitNo, // 就诊号
          visitNumber: fd.visitNumber,
          patientAge: fd.patientAge + fd.patientAgeUnit, // 年龄
          patientSource: fd.patientSource, // 值域：1-门诊；2-住院；3-体检；5-急诊
          medicalCardNo: fd.medicalCardNo, // 就诊卡号
          medicalRecordNo: fd.medicalRecordNo, // 病历号
          clinicCode: fd.clinicCode, // 门诊号
          hospizationCode: fd.hospizationCode, // 住院号
          visitDateTime: fd.visitDateTime, // 就诊时间
          visitDeparmentCode: fd.visitDeparmentCode, // 就诊科室代码
          visitDeparment: fd.visitDeparment, // 就诊科室
          attendDoctorCode: fd.attendDoctorCode, // 接诊医生代码
          attendDoctor: fd.attendDoctor, // 就诊医生
          diagnosis: fd.diagnosis, // 诊断
          icD10: fd.icD10, // icd10
          bedNo: fd.bedNo, // 床号
          wardName: fd.wardName, // 病区
          wardNo: fd.wardNo, // 病区代码
          roomNo: fd.roomNo // 病房号
        },
        examinations: []
      }
      const examinationsObj = {
        applyCode: fd.applyCode, // 申请单号
        medicalAdviceNo: fd.medicalAdviceNo, // 医嘱号
        examClass: fd.examClass, // 申请单类型  类型代码:CT/MRI/US等  检查部门
        examClassCode: fd.examClassCode, // 申请单类型代码
        clinicdiagnosis: fd.clinicdiagnosis, // 临床诊断
        chiefComplaint: fd.chiefComplaint, // 主诉
        diseasesHistory: fd.diseasesHistory, // 电子病史
        physicalSign: fd.physicalSign, // 体征
        xno: fd.xno,
        allergicHistory: fd.allergicHistory, // 过敏史
        drugResistanceHistory: fd.drugResistanceHistory, // 耐药史
        examPurpose: fd.examPurpose, // 检查目的
        isEmergency: fd.isEmergency,
        applyDepartment: fd.applyDepartment, // 申请单科室
        applyDepartmentCode: fd.applyDepartmentCode, // 申请科室代码
        applyDoctor: fd.applyDoctor, // 申请医生
        applyDoctorCode: fd.applyDoctorCode, // 申请医生代码
        examText: fd.examText, // 申请单项目
        cost: fd.cost, // 总价
        examExecuteDepartmentCode: fd.examExecuteDepartmentCode, // 执行科室代码
        examExecuteDepartment: fd.examExecuteDepartment, // 执行科室
        remarkInfo: fd.remarkInfo, // 备注
        effectiveFlag: fd.effectiveFlag,
        applyDateTime: dateFormatter(new Date()), // 申请时间
        examStatus: fd.examStatus, // 值域：0-已登记；1-已检查；2-已报告；3-已审核；4-已作废；5-原始；
        feeStatus: fd.feeStatus, // 是否收费
        invoiceNo: fd.invoiceNo
      }
      params.examinations[0] = examinationsObj
      return params
    },
    handleApplyDepartMentChange(val) {
      this.loading = true
      this.cancelCheckedChange()
      this.formdata.modalitytype = ''
      // console.log('handleApplyDepartMentChange')
      this.filterList()
      setLocalStorage('yjyy@applyDepart', val)
      this.getFormDefaultLoaclStorage('set')
      this.modalitytypeShow ? this.getModalityTypeList() : null
    },
    handleWardNoChange(val) {
      // console.log('handleWardNoChange')
      this.loading = true
      this.cancelCheckedChange()
      this.formdata.modalitytype = ''
      this.filterList()
      setLocalStorage('yjyy@wardno', val)
      this.getFormDefaultLoaclStorage('set')
      this.modalitytypeShow ? this.getModalityTypeList() : null
    },
    handleExecuteDepartMentChange(val) {
      console.log('handleExecuteDepartMentChange')
      this.loading = true
      this.cancelCheckedChange()
      setLocalStorage('yjyy@executeDepart', val)
      // 检查部门字段传到接口里没用，所以暂时用前端过滤，不要去调用接口
      this.formdata.modalitytype = ''
      this.collapseShow = this.formdata.executeDepartMents.length > 2
      this.filterList()
      this.getFormDefaultLoaclStorage('set')
      this.modalitytypeShow ? this.getModalityTypeList() : null
    },
    changeInput() {
      // this.isMpiOrPid && this.formdata.queryWay == 0 ? this.formdata.queryText = this.formdata.queryText.toUpperCase() : null
      // 温附二申请单和已预约列表查询的时候，8位非0开头的跳PID，0开头的跳住院号，其他就是卡号，而且遇到小写p开头的且是8位数的，p要自动转化为大写。
      // 温附二住院号有时候是1开头的，当09999999的时候，下一个就是1*******，但99.9%的情况下，住院号都是0开头，所以出现1的情况的时候，就不用管了，让手动切换
      let qText = this.formdata.queryText.trim()
      if (this.isMpiOrPid) { // this.isMpiOrPid为true代表的是温附二环境
        if (qText.length == 8 && qText.substr(0, 1).toUpperCase() == 'P') {
          this.formdata.queryWay = 0 // PID
          this.formdata.queryText = qText.toUpperCase()
          this.search()
        }
        if (qText.length == 8 && (qText.substr(0, 1) == '0') && (qText.substr(0, 3) != '000')) {
          this.formdata.queryWay = 3 // 住院号
          this.search()
        }
        // if (qText.length == 20 && (qText.substr(0, 3) == '000')) {
        //   // 温附二的健康卡20位 00021211502052131632 查询的是病人ID，然后门诊卡的20位，查询的可能是卡号，有点冲突，待处理
        //   console.log('this.jskQueryWay', this.jskQueryWay)
        //   this.formdata.queryWay = this.jskQueryWay || 1 // 1:卡号，10:病人ID
        //   this.search()
        // }
        // if (qText.length == 8 && qText.substr(0, 1) != '0' && qText.substr(0, 1) != '1') {
        //   this.formdata.queryWay = 0 // PID
        // }
      }
    },
    // 复制
    copyText(text) {
      const input = document.createElement('input')
      input.value = text
      document.body.appendChild(input)
      input.select()
      document.execCommand('copy')
      document.body.removeChild(input)
    },
    search() {
      // this.mix_tableData = []
      // this.mix_saveDATA = []
      this.isAlreadyShow = false
      // this.tableColumns = this.getTableColumns()
      if (!this.isCanSearch()) return
      // 每次查询的时候需清空所选择的患者信息
      this.$store.commit('patient/SELECTEDPATIENTINFO', {})
      this.$store.commit('patient/SETROWCURR', { isJZ: false, isVIP: false, privacyLevel: '' })
      // 温州市中心医院：
      // 市民卡41位，门诊卡17位，电子医保凭证28位 8F5E1F982425936E861E57384149
      // 温附二：住院卡8位
      // 文成县人民医院：就诊卡卡号长度20位
      // 福鼎市医院： 市民卡9位 门诊卡33位 医保卡28位
      // 健康卡 60位，32C9225303E77060E6126920178958618F5E1F982425936E861E57384149
      // 温附二：住院卡8位，PID8位，健康卡 60位 病人ID 20位
      // 温附二PID是8位，申请单和已预约列表查询的时候，8位非0开头的跳PID，0开头的跳住院号，其他就是卡号，而且遇到小写p开头的且是8位数的，p要自动转化为大写。
      let qText = this.formdata.queryText.trim()
      // 眼视光医院当查询自费卡的时候，若没看过病的人刷卡会返回1或0，可直接拦截，不去查询申请单并提示未查到病人信息
      if (!isNull(qText) && (Number(qText) === 0 || Number(qText) === 1)) {
        this.$message.warning('未查到病人信息')
        return
      }
      if (qText) {
        try {
          // 复制
          this.copyText(qText)
        } catch (e) {
          // TODO handle the exception
        }
        this.$refs.WSCardReader.searchJudge(qText, (res) => {
          // 进入回调，直接查询，因为不需要经过读卡器服务
          const qw = getQueryWayByText(res.searchWay)
          if (!isNull(qw)) {
            this.formdata.queryWay = qw
          }
          if (!isNull(res.patientSource)) {
            this.formdata.patientSource = res.patientSource
          }
          this.doSearch()
        }, (res) => {
          // 进入回调, 但不查询，因为需要把编码传给读卡器服务
          const qw = getQueryWayByText(res.searchWay)
          if (!isNull(qw)) {
            this.formdata.queryWay = qw
          }
        })
      } else {
        // console.log('else2=>doSearch')
        this.doSearch()
      }
    },
    doCardInit() {
      if (this.kyCardReaderOptions && this.kyCardReaderOptions.length > 0) {
        this.kyCardReaderOptions[1].data.CardId = this.formdata.queryText
        this.$store.dispatch('patient/setCardId', this.formdata.queryText).then(() => {
          this.$nextTick(() => {
            this.$refs.WSCardReader.readerCardOption = this.kyCardReaderOptions
          })
        })
      } else {
        alert('请先在config.js中配置读卡器参数')
      }
      this.$nextTick(() => {
        this.$refs.WSCardReader.readerType = 'sbjzfds-fj' // 磁条卡
        this.$refs.WSCardReader.wsInit()
      })
    },
    doSearch() {
      // if (this.loading) {
      //   this.$message.warning('上一次查询尚未结束，请稍等片刻')
      //   return
      // }
      // 对于下一次请求被上一次请求所覆盖的处理
      if (!this.formdata.queryText) {
        doSearchArr.all.requestTime = new Date().getTime()
      } else {
        doSearchArr.some.requestTime = new Date().getTime()
      }
      this.handleInit()
      this.getHisExamList()
      // debounce(() => {
      //   console.log('查询防抖')
      //   this.loading = true
      //   this.handleInit()
      //   this.getHisExamList()
      // }, 1500)
    },
    // 获取HIS检查列表
    getHisExamList() {
      this.loading = true
      const userInfo = this.$store.state.user.userInfo
      // 如果是福鼎市医院，住院号查询，只取前面6位的值
      const patientName = (this.formdata.patientName && (this.formdata.patientName).trim()) || ''
      const queryText = (this.formdata.queryText && (this.formdata.queryText).trim()) || ''
      // 有卡号、PID等的时候，姓名输入框自动清空
      if (queryText) {
        this.formdata.patientName = ''
      }
      // const beginTime = new Date(this.formdata.hisFormDate[0])
      // const endTime = new Date(this.formdata.hisFormDate[1])
      // 计算时间戳差距
      // const timeDiff = Math.abs(endTime.getTime() - beginTime.getTime())
      // 计算天数差距
      // const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24))
      if ((patientName || queryText) && !this.isFocusRadio) {
        this.formdata.dateRadio = ''
        // console.error('来这里了吗', this.isFocusRadio)
        this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - (this.defHisDay - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
        // this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - Math.abs(~~this.formdata.dateRadio - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
        // this.isFocusRadio = true
        if (this.defHisDay == 1 || this.defHisDay == 3 || this.defHisDay == 7 || this.defHisDay == 30) {
          this.formdata.dateRadio = this.defHisDay + ''
        }
        // this.getFormDefaultLoaclStorage('set')
      }
      this.timeout04 = setTimeout(() => {
        // // console.log('this.formdata.hisFormDate', this.formdata.hisFormDate)
        let params = {
          patientName: (this.formdata.patientName && (this.formdata.patientName).trim()) || '',
          queryWay: this.formdata.queryWay, // 查询方式 0-病人id 1-卡号 2-门诊号 3-住院号 4-发票号 5-申请单号 6-身份证号 7 社保卡号 暂时不用 8 手机号 默认0
          queryValue: queryText,
          requestStartDateTime: this.formdata.hisFormDate ? (this.formdata.hisFormDate[0]) + ' 00:00:01' : '', // 申请单开始时间
          requestEndDateTime: this.formdata.hisFormDate ? (this.formdata.hisFormDate[1]) + ' 23:59:59' : '', // 申请单结束时间
          // examClass: this.formdata.examClass, // 检查类型 检查设备
          // organizationNo: this.formdata.depArea, // 影像区域名称
          examClass: this.modalitytypeShow ? this.formdata.modalitytype : '', // 设备类型
          executeDepartMent: this.isChooseDeps ? this.formdata.executeDepartMents.join(',') : this.formdata.executeDepartMent, // 执行科室
          organizationCode: this.hospitalCode, // 申请医院代码
          hospitalCode: this.hospitalCode, // 预约医院代码 如果没传会取申请医院代码
          operateCode: userInfo.userCode, // 操作人编号 可传工号
          operateUser: userInfo.userName, // 操作人姓名
          patientSource: this.formdata.patientSource // 病人类型 1 门诊 2 住院 3 体检 4 绿检 5急诊 6外院、0未知 默认0
        }
        if (this.depAreaShow) {
          params['organizationNo'] = this.formdata.depArea
        }
        if (this.isShowApplyDepart) {
          params['applyDepartment'] = this.formdata.applyDepartment || ''
          params['applyDepartmentCode'] = this.formdata.applyDepartmentCode || ''
        }
        console.warn('==params==', params)
        const SM2EncryptData = enc.SM2Encrypt(JSON.stringify(params), this.pubcliKey)
        const data = {
          organizationCode: this.hospitalCode,
          data: '04' + SM2EncryptData
        }
        this.checkAll = false
        this.isIndeterminate = false
        postHisExamEncrypt(data).then(res => {
          this.isVIP = false
          this.isJZ = false
          this.loading = false
          if (res && res.code === 10000) {
            // console.log('=================================================')
            // console.log('this.formdata.queryText', this.formdata.queryText, new Date().getTime())
            // 对于下一次请求被上一次请求所覆盖的处理
            if (!this.formdata.queryText || (res.content.list && res.content.list.length > 10)) {
              doSearchArr.all.responseTime = new Date().getTime()
            } else {
              doSearchArr.some.responseTime = new Date().getTime()
            }
            console.log('doSearchArr', doSearchArr)
            // 判断两次查询时间是否在10秒之内
            const twoSearchRequestTime = doSearchArr.some.requestTime - doSearchArr.all.requestTime
            console.log('twoSearchRequestTime', twoSearchRequestTime)
            if (twoSearchRequestTime > 0 && twoSearchRequestTime < 10000) {
              // 如果查询all的请求时间小于查询some的请求时间&&查询all的数据返回时间大于查询some的数据返回时间&&查询some的数据返回时间大于查询some的请求时间(查询some已返回数据)
              if (doSearchArr.all.requestTime < doSearchArr.some.requestTime && doSearchArr.all.responseTime > doSearchArr.some.responseTime && doSearchArr.some.requestTime < doSearchArr.some.responseTime) {
                console.log('上次请求返回的数据被中断')
                return
              }
            }
            console.log('doSearchArr.some.requestTime - doSearchArr.all.requestTime', doSearchArr.some.requestTime - doSearchArr.all.requestTime)
            // 请求时间大于返回时间，说明还没返回(请求all的时间大于请求all的返回时间 && 请求some的时间小于请求some的返回时间&&请求all的时间小于请求some的时间)
            // if (doSearchArr.all.requestTime > doSearchArr.all.responseTime && doSearchArr.some.requestTime < doSearchArr.some.responseTime && doSearchArr.all.requestTime < doSearchArr.some.requestTime) {
            //   // 说明是上一次非查询某个人的查询尚未返回数据
            // }
            if (!res.content.list || !res.content.list.length) {
              this.$store.commit('patient/SELECTEDPATIENTINFO', {})
              let objCurr = Object.assign({}, this.rowCurr, { isJZ: false, isVIP: false, privacyLevel: '' })
              this.$store.commit('patient/SETROWCURR', objCurr)
            } else {
              // 查询到列表的时候，底部tab需要自动切换到【HIS申请】，但这个切换不影响手工登记页面，所以this.hisActivedIndex != 2代表只在HIS申请页面和已预约列表页面切换
              if (this.hisActivedIndex != 2 && (this.formdata.queryText || this.formdata.patientName)) {
                // // console.log('&&&&&&&&&&&&&执行到了这里&&&&&&&&&&&&&')
                let newRow = this.setRowCurrEvent(this.formdata)
                // // console.log('查看这里newRow', newRow)
                this.$store.commit('patient/SELECTEDPATIENTINFO', newRow)
                if (this.isShowTwoList && !this.isSaveInput) {
                  if (this.hisActivedIndex != 3) {
                    store.dispatch('patient/setHisActivedIndex', 3)
                    this.$parent.$parent.btnTypeChange(3)
                  }
                } else {
                  store.dispatch('patient/setHisActivedIndex', 1)
                  this.$parent.$parent.btnTypeChange(1)
                }
              }
            }
            // 先判断所查结果总条数，若小于显示条数，就照常处理数据；若大于则截取
            if (res.content.list.length < (this.listLimit || 500)) {
              console.log('照常查询')
              this.getHisTableList(res.content.list)
            } else {
              console.log('结果截取')
              // 申请单加载条数上限的截取方式，前或后
              if (this.numSpliceIsFront) {
                this.getHisTableList(res.content.list.splice(0, this.listLimit || 500))
              } else {
                this.getHisTableList(res.content.list.splice(res.content.list.length - ((this.listLimit || 500) + 1), this.listLimit || 500))
              }
            }
          } else {
            // !logoutFlag ? this.$message.warning(res.message || `查询返回错误：${res.code}！`) : null
            let resultTip = ''
            if (res.message) {
              resultTip = res.message
            } else {
              resultTip = '查询返回错误, 请联系管理员'
            }
            this.$message.warning(resultTip)
            // console.log('process.env.NODE_ENV', process.env.NODE_ENV)
            // if (process.env.NODE_ENV === "development") {
            //   this.getHisTableList(res.content.list.splice(0, this.listLimit || 500))
            // }
          }
        })
      }, 200)
      this.isToSearch = true
      this.isFocusRadio = false
    },
    getOverBed(info) {
      let OverBed = ''
      if (info && info.extras && info.extras.length > 0) {
        info.extras.forEach(element => {
          if (element.key == 'Bedside') {
            OverBed = element.value
          }
        })
      }
      return OverBed
    },
    // 查询结果列表数据
    getHisTableList(data) {
      // console.log('data', data)
      // 模拟急诊标签
      // data[0].examinations[0].emergency = 1
      // data[1].examinations[0].emergency = 1
      // data[2].examinations[0].emergency = 2
      // data[3].examinations[0].emergency = 3
      let _data = []
      const checkTableConfig = this.appConfig ? this.appConfig.checkHisTable : this.emergencyTypes // this.appConfig ? this.appConfig.checkHisTable : Options.emergencyOptions
      // console.log('getHisTableList=>checkTableConfig', checkTableConfig)
      let _data1 = [] // 已预约
      let _data2 = [] // 未预约
      let _data3 = [] // 优先级
      // console.log('data', data)
      // let tipContentArr = [] // 当项目列表为空数组的时候，需要提示哪些patientId的患者项目列表没维护，然后提示医生护士让管理员去维护
      data.forEach(item => {
        let isBed = false // 是否是床旁
        let examinationsObj = (item.examinations && item.examinations.length && item.examinations[0]) || {}
        let examinationString = []
        let examinationPartString = []
        // let cost = 0
        if (examinationsObj.examItems) {
          // 多个部位拼接
          examinationsObj.examItems.forEach(itemExamination => {
            examinationString.push(itemExamination.examItemName)
            // cost = cost + itemExamination.price
            itemExamination.examParts.forEach(itemExamParts => {
              if (examinationPartString.indexOf(itemExamParts.examPart) == -1) {
                examinationPartString.push(itemExamParts.examPart)
              }
            })
          })
          // if (cost > 0) {
          //   cost = cost.toFixed(2)
          // }
          // 是否床旁
          if (!isBed && examinationsObj.extras && examinationsObj.extras.length > 0) {
            for (let indexExtra = 0; indexExtra < examinationsObj.extras.length; indexExtra++) {
              if (examinationsObj.extras[indexExtra].key == 'Bedside' && examinationsObj.extras[indexExtra].value == '床旁') {
                isBed = true
              }
            }
          }
        }
        try {
          let appointDateTimeFull = ''
          let appointDateTime2 = ''
          let examItemCode = ''
          let appointDateTimeStamp = ''

          if (item.examinations && item.examinations.length && item.examinations[0].appointDateTime && item.examinations[0].appointTimePeriod) {
            appointDateTimeFull = item.examinations[0].appointDateTime ? dateFormatter(item.examinations[0].appointDateTime) + ' ' + item.examinations[0].appointTimePeriod : ''
            appointDateTime2 = dateFormatter(item.examinations[0].appointDateTime)
          } else if (item.examinations && item.examinations.length && item.examinations[0].appointDateTime) {
            appointDateTimeFull = dateFormatter(item.examinations[0].appointDateTime)
            appointDateTime2 = dateFormatter(item.examinations[0].appointDateTime)
          }
          if (item.examinations && item.examinations.length && item.examinations[0].examItems && item.examinations[0].examItems.length) {
            examItemCode = item.examinations[0].examItems[0].examItemCode || ''
          } else {
            // tipContentArr.push(item.patient.patientId)
          }
          if (item.examinations && item.examinations.length) {
            appointDateTimeStamp = item.examinations[0].applyDateTime ? new Date(item.examinations[0].applyDateTime).getTime() : 0
          }
          let _obj = {
            patient: item.patient,
            patientEnName: pinyin.getFullChars(item.patient.patientName),
            visit: item.visit,
            patientType: item.visit.patientSource ? this.patSourceOptions.filter(it => it.value == item.visit.patientSource)[0].name : '',
            examinations: item.examinations,
            genderTxt: this.getGender(item.patient.gender),
            patAgeTxt: this.getPatAge('', '', item.visit.patientAge),
            appointDateTimeFull: appointDateTimeFull, // 显示的预约时间
            appointDateTime2: appointDateTime2, // 预约时间
            examStatusTxt: item.examinations && item.examinations.length && this.getExamStatusVal(item.examinations[0].examStatus), // 状态转换成文字
            examItemCode: examItemCode,
            examItemName: examinationString.join(','),
            examPart: examinationPartString.join(','),
            cost: item.cost, // 金额
            price: item.cost, // item.examinations[0].examItems[0].price,
            checked: false, // 列表数据是否选中
            vip: '否', // 是否vip用户
            isBed: isBed,
            appointDateTimeStamp: appointDateTimeStamp,
            violationcount: item.examinations && item.examinations.length && this.getViolationCount(item.examinations[0]), // 违约次数
            bedside: item.examinations && item.examinations.length && this.getOverBed(item.examinations[0]), // 床旁非床旁
            grade: item.examinations && item.examinations.length && this.getEmergencyTip(item.examinations[0].emergency), // 急诊标志
            emergencyInfo: item.examinations && item.examinations.length && this.getEmergencyTip(item.examinations[0].emergency), // 急诊标志
            chargeType: item.examinations && item.examinations.length && item.examinations[0].feeType
          }
          if (this.isSetGrade && item.examinations && item.examinations.length) {
            _obj.emergencyCopyFlag = item.examinations[0].emergency
          }
          if (item.examinations && item.examinations.length) {
            for (let k1 in item.examinations[0]) {
              _obj[k1] = item.examinations[0][k1]
              if (k1 == 'feeStatus') {
                _obj[k1] = item.examinations[0][k1] ? '已收费': '未收费'
              }
            }
          }
          for (let k2 in item.visit) {
            _obj[k2] = item.visit[k2]
          }
          for (let k3 in item.patient) {
            _obj[k3] = item.patient[k3]
          }
          // _obj.cost = cost // 金额
          // 计算减少一次循环 2000次。
          if (_obj.emergency > 0 && _obj.examStatusTxt == '未登记') {
            _data3.push(_obj) // 优先级
          } else if ([0, 1, 2, 3].indexOf(_obj.examStatus) > -1) {
            _data1.push(_obj) // 已预约
          } else {
            _data2.push(_obj) // 未预约
          }
          // 用于测试优先级和急诊标志
          // _obj.emergency = 16
          // _obj.emergencyInfo = this.getEmergencyTip(16) // 急诊标志
          // 如果患者类型是住院并且是温州市中心医院，则进行下面的判断
          if (this.formdata.patientSource == 2 && (this.applyInfoHospital == 'wzszxyy' || this.hospitalCode === '47052555733030211A1001') && !this.isShowDayTag) {
            this.isShowDayTag = (_obj && _obj.applyDepartment && _obj.applyDepartment.includes('住院服务中心')) || (_obj && _obj.wardName && _obj.wardName.includes('住院服务中心'))
          }
          // -----------------------------------------------------------------
          // 造一个可以用于显示和处理勾选状态的收费类型数组（用于检查项目的拆分）
          if (((this.applyInfoHospital === 'wzszxyy' || this.hospitalCode === '47052555733030211A1001') && this.userDepartment === '超声科') || this.$hasPermission['YJYY10008056']) {
            let orderBillInfo = []
            _obj.orderBillDetails.forEach(element => {
              let newArray = JSON.parse(JSON.stringify(element))
              newArray.applyCode = _obj.applyCode
              newArray.checked = true
              orderBillInfo.push(newArray)
            })
            // _obj.orderBillDetails = orderBillDetails
            _obj.orderBillInfo = JSON.parse(JSON.stringify(orderBillInfo))
            _obj.orderCheckedAll = true
            _obj.orderCheckedHalf = false
          }
          // -------------------------------------------------------------------
          _data.push(_obj)
        } catch (e) {
          console.warn('catch', e)
        }
      })
      // console.warn('_data', _data)
      // console.warn('已预约_data1', _data1)
      // console.warn('未预约_data2', _data2)
      // console.warn('优先级_data3', _data3)
      // 如果存在项目列表为空的情况，需要有个提示
      // 手动去查询的时候再提示多个人的申请单有问题的提示
      // if (this.notAutoSearchPatSource && this.notAutoSearchPatSource.length && this.notAutoSearchPatSource.includes(this.formdata.patientSource)) {
      //   if (tipContentArr.length) {
      //     this.tipContent = `patientId为${tipContentArr.join('、')}的申请单的项目列表未维护，如果需要维护或者因此导致无法预约，请联系管理员进行数据维护`
      //     this.dialogTipVisible = true
      //   }
      // } else { // 或者就只提示查询单个人的
      //   if (this.formdata.patientName || this.formdata.queryText) {
      //     if (tipContentArr.length) {
      //       this.tipContent = `patientId为${tipContentArr.join('、')}的申请单的项目列表未维护，如果需要维护或者因此导致无法预约，请联系管理员进行数据维护`
      //       this.dialogTipVisible = true
      //     }
      //   }
      // }
      // 申请时间排序
      let ddSort = (a, b) => {
        if (window.g.applyListSort) {
          return a.appointDateTimeStamp - b.appointDateTimeStamp
        } else {
          return b.appointDateTimeStamp - a.appointDateTimeStamp
        }
      }
      // 这里把急诊变成中文
      // 配置急诊标志排序
      // const emergencySort = (a, b) => {
      //   const aObj = checkTableConfig.find(ctc => ctc.name === this.getEmergencyTip(a.emergency))
      //   // // // // // console.log('aObj', aObj)
      //   const bObj = checkTableConfig.find(ctc => ctc.name === this.getEmergencyTip(b.emergency))
      //   // // // // // console.log('bObj', bObj)
      //   const asort = aObj ? Number(aObj.sort) : 100
      //   const bsort = bObj ? Number(bObj.sort) : 100
      //   return bsort - asort
      // }
      // 设置假数据 开发环境下可自由模拟修改数据库返回的数据，忘记注释并部署到正式环境后，也没关系

      // if (_data.length > 0) {
      //   _data[0].emergency = 1
      //   // _data[0].examStatus = 0
      //   // _data[0].examStatusTxt = '已登记'
      // }
      // if (_data.length > 1) {
      //   _data[1].emergency = 2
      // }
      // if (process.env.NODE_ENV != 'production' || window.g.isTestDataInApplyHIS) {
      //   if (_data.length > 0) {
      //     _data[0].emergency = 1
      //     // _data[0].examStatus = 0
      //     // _data[0].examStatusTxt = '已登记'
      //   }
      //   if (_data.length > 1) {
      //     _data[1].emergency = 2
      //   }
      // }
      // // // // // console.log('_data====>', _data)
      // let ssSort = (a, b) => {
      //   return Number(a.sort) - Number(b.sort)
      // }
      let dataEmergency = {}
      let dataEmergencyNameObj = []
      let data3Len = _data3.length
      // console.log('data3Len', data3Len)
      // 这里有问题
      // 先排出来急诊病人的顺序
      // this.appConfig.checkHisTable = this.appConfig.checkHisTable ? this.appConfig.checkHisTable.sort(ssSort) : Options.emergencyOptions
      // let checkHisTableJson = JSON.parse(JSON.stringify(this.appConfig.checkHisTable))
      let checkHisTableJson = JSON.parse(JSON.stringify(this.appConfig.checkHisTable || this.emergencyTypes))
      // console.warn('checkHisTableJson', checkHisTableJson)
      checkHisTableJson.forEach(item => {
        // 按顺序输出 急诊 术前的顺序
        dataEmergencyNameObj.push(item.name || item.label)
        dataEmergency[item.name || item.label] = []
      })
      // // console.log('dataEmergencyNameObj', dataEmergencyNameObj)
      // // console.log('dataEmergency', dataEmergency)
      for (let i = data3Len - 1; i >= 0; i--) {
        // console.warn('_data3[i]', _data3[i])
        // // console.log('_data3[i].emergency', _data3[i].emergency)
        // console.warn('_data3[i].emergencyInfo', _data3[i].emergencyInfo)
        if (dataEmergency[_data3[i].emergencyInfo]) {
          dataEmergency[_data3[i].emergencyInfo].push(_data3[i])
        } else {
          dataEmergency[_data3[i].emergencyInfo] = []
          dataEmergency[_data3[i].emergencyInfo].push(_data3[i])
        }
      }
      // console.warn('dataEmergency', dataEmergency)
      for (let key in dataEmergency) {
        if (dataEmergency[key].length) {
          dataEmergency[key] = dataEmergency[key].sort(ddSort)
        }
      }

      let dataEmergencyAll = []
      // 按照字符串的顺序输出合并数组
      // console.warn('checkTableConfig', checkTableConfig)
      if (checkTableConfig.length) {
        dataEmergencyNameObj.forEach((item) => {
          // console.warn('item', item)
          // console.warn('dataEmergency[item]', dataEmergency[item])
          dataEmergencyAll = dataEmergencyAll.concat(dataEmergency[item])
        })
      } else {
        dataEmergencyAll = _data3.sort(ddSort)
      }
      // console.warn('dataEmergencyAll', dataEmergencyAll)
      let dataAll = []
      this.tableDataAll = []
      let sortByBedNo = (a, b) => {
        if (a.bedNo && b.bedNo) {
          return a.bedNo - b.bedNo
        } else {
          return a.appointDateTimeStamp - b.appointDateTimeStamp
        }
      }
      // 住院条件下是否根据床号排序
      if (this.isBedNoSort && this.formdata.patientSource == 2) {
        // // console.log('根据床号排序')
        dataEmergencyAll = dataEmergencyAll.sort(sortByBedNo)
        dataAll = _data2.sort(sortByBedNo)
        this.tableDataAll = dataEmergencyAll.concat(dataAll.concat(_data1.sort(sortByBedNo)))
      } else {
        // 急诊显示再上面，非急诊显示再下面, 未预约显示再上面，已经预约显示再下面（按照预约时间升序排列）
        dataAll = _data2.sort(ddSort)
        this.tableDataAll = dataEmergencyAll.concat(dataAll.concat(_data1.sort(ddSort)))
      }
      // const dataEmergencyAll = checkTableConfig ? _data3.sort(emergencySort) : _data3.sort(ddSort)
      // 未预约列表.sort(ddSort)
      // const dataAll = _data2
      // let dataAll = _data2.sort(ddSort)
      // 未预约显示再上面，已经预约显示再下面（按照预约时间升序排列）
      // this.tableDataAll = dataEmergencyAll.concat(dataAll.concat(_data1.sort(ddSort)))
      // console.log('_data', _data)
      // console.warn('=>查看这里this.tableDataAll', this.tableDataAll)
      this.handleInit()
      this.tableDataShowAll = this.tableDataAll
      console.log('=======================end==========================')
      console.log('this.formdata.queryText', this.formdata.queryText, new Date().getTime())
      this.filterList()
      // this.rowCurr = {}
      if (this.isAutoRefresh == true && this.formdata.patientSource == 3 && (this.hisActivedIndex == 3 || this.hisActivedIndex == 1)) {
        // 福鼎医院体检的申请单列表需要实时刷新
      } else {
        // // console.log('(this.formdata.queryText || this.formdata.patientName) && this.mix_tableData && this.mix_tableData.length', (this.formdata.queryText || this.formdata.patientName) && this.mix_tableData && this.mix_tableData.length)
        if ((this.formdata.queryText.trim() || this.formdata.patientName.trim()) && this.mix_tableData && this.mix_tableData.length) {
          // console.log('into tipLevelFunction')
          (this.applyInfoHospital === 'wzszxyy' || this.hospitalCode === '47052555733030211A1001') ? this.tipHaveLevelFunction(this.mix_tableData) : null
          // // console.log('==>3')
          this.handleRowCurr2(this.mix_tableData[0], 0, null)
        } else {
          // this.$store.dispatch('patient/setRowCurr', {})
        }
      }
      _data = null
      _data1 = null
      _data2 = null
      _data3 = null
      dataAll = null
    },
    // 自动选择当前查询用户的申请单,这个函数在查询申请单的时候会触发，自动进行联合预约
    autoCheckedApplyAppo() {
      console.log('autoCheckedApplyAppo')
      // examStatus	integer($int32) -1 - HIS取消 0 - 已登记 1 - 已检查 2 - 已报告 3 - 已审核 4 - 已作废 5 - 原始 必填
      let checkedArr = []
      // let checkedApplyId = ''
      this.tableDataAll.forEach(item => {
        let _item = JSON.parse(JSON.stringify(item))
        // 这里的过滤，是因为公司的环境，是返回所有数据的
        // if (item.idCard === this.formdata.queryText && (!checkedApplyId || checkedApplyId === item.applyCode)) {
        if (!this.isCheckExamStatus || (this.isCheckExamStatus && (_item.examStatus === -1 || _item.examStatus > 3))) {
          _item.checked = true
        }
        checkedArr.push(_item)
        // checkedApplyId = _item.applyCode
        this.checkedPatId = _item.patientId
      })
      // // // console.log('checkedApplyId', checkedApplyId)
      this.tableDataShowAll = checkedArr
      // console.log('filterList=>autoCheckedApplyAppo', this.tableDataShowAll.length)
      if (this.tableDataShowAll.length) {
        this.filterList()
      }
      if (this.checkedPatId) {
        // console.log('this.mix_tableData', this.mix_tableData)
        if (this.mix_tableData && this.mix_tableData.length) {
          this.mix_tableData.forEach(item => {
            // 住院的患者检查科室为住院服务中心的时候提示该患者为日间病房患者，请优先预约
            // this.tipLevelFunction(item)
          })
        }
        let _obj = this.mix_tableData.find(dd => dd.checked)
        if (_obj) {
          // console.log('_objxingming')
          // this.rowCurr = _obj
          _obj = this.setCheckedInitStatus(_obj)
          this.$store.dispatch('patient/setRowCurr', _obj)
        }
        this.timeout06 = setTimeout(() => {
          // // console.log('到这里了哦')
          if (!this.isShowTwoList) {
            this.appointmentPostMessageUnion()
          } else {
            // this.$store.dispatch('patient/setHisActivedIndex', 3)
            // this.$parent.$parent.btnTypeChange(3)
          }
        }, 200)
      }
      this.checkallChange()
    },
    // 查询方式改变
    queryWayChange() {
      console.log('formdata.queryWay', this.formdata.queryWay)
      this.setPatientSourceToqueryWay()
      this.$nextTick(() => {
        this.$refs.formQueryTextIpt && this.$refs.formQueryTextIpt.focus()
      }, 100)
    },
    // 预约
    appointment(row) {
      // // // console.log(row)
      const aurl = this.appoint_url
      if (!aurl) {
        this.$message.info('未配置预约地址！')
        return
      }
      const applyIds = '' // 检查申请单编号（单独对指定申请单进行操作）
      const userInfo = this.$store.state.user.userInfo
      const _url = `${aurl.indexOf('?') >= 0 ? aurl + '&' : aurl + '?'}hospitalCode=${this.hospitalCode}&hospitalName=${this.hospitalName}&patientId=${row.patientId}&operateUser=${userInfo.userName}&operateCode=${userInfo.userCode}&examClass=${row.examClass}&idCard=${row.idCard}&applyCode=${applyIds}&tel=&ps=${row.patientSource}&pw=0&edm=${row.examExecuteDepartment}`
      this.applyCheckUrl = _url
      // console.log('appointment=>this.applyCheckUrl', this.applyCheckUrl)
    },
    // 联合预约嵌套触发
    appointmentPostMessage(row) {
      console.log('=======appointmentPostMessage========')
      console.log('this.applyCodes', this.applyCodes)
      console.log('row', row)
      if (this.oldRow.patientId != row.patientId || this.oldRow.patientId != row.patientId) {
        this.formdata.fromCheckDepartment = false
      } else if (Object.values(this.oldRow).length === 0) {
        this.oldRow = JSON.parse(JSON.stringify(row))
      }
      console.log('appointmentPostMessage=>row', row)
      // console.log('%%%%%%%%%%%rowCurr%%%%%%%%%%%%%', this.rowCurr)
      let checkBed = ''
      if (!this.appoint_url) {
        this.$message.info('未配置预约地址！')
        return
      } else {
        let patList = JSON.parse(JSON.stringify(this.getCheckedPatList(this.applyCodes)))
        const userInfo = this.$store.state.user.userInfo
        const applyIds = this.applyCodes || '' // 检查申请单编号（单独对指定申请单进行操作）
        this.applyCodeFrom = []
        // let examItemChangeId = []
        // console.log('this.rowCurr', this.rowCurr)
        // console.log('patList', patList)
        for (let i = 0; i < patList.length; i++) {
          if (patList[i] && patList[i].patientId && patList[i].patientId != null && patList[i].patientId === this.rowCurr.patientId) {
            // console.error('patList[i]', patList[i])
            // console.error('setOverBed', this.setOverBed)
            // this.isConfigBedside && Object.keys(this.setOverBed).length != 0 ? patList[i] = this.changeListDataBed(patList[i], this.setOverBed) : null
            // patList[i].applyCode === row.applyCode ? patList[i].orderBillInfo = row.orderBillInfo : null
            checkBed = this.isConfigBedside && patList[i].isOverBed ? '' : getLocalStorage('UserPermision') || ''
            patList[i].isOverBed = this.setOverBed.isOverBed ? this.setOverBed.isOverBed : patList[i].isOverBed
            if (patList[i].examinations && patList[i].examinations.length > 0) {
              patList[i].examinations.forEach(element => {
                element.isOverBed = this.setOverBed.isOverBed ? this.setOverBed.isOverBed : element.isOverBed
                // 在遍历额外信息之前，先检查额外信息是否存在
                if (element.extras && element.extras.length > 0) {
                  for (const extra of element.extras) {
                    if (extra && extra.key === 'Bedside') {
                      extra.value = this.setOverBed.isOverBed ? '床旁' : extra.value
                    }
                  }
                }
                element.privacyLevel = this.rowCurr.PrivacyLevel || this.rowCurr.privacyLevel || ''
              })
            }
            if (patList[i].extras && patList[i].extras.length > 0) {
              patList[i].extras.forEach(element => {
                element.key === 'Bedside' ? (this.setOverBed.isOverBed ? element.value = '床旁' : element.value) : null
              })
            }
            // 申请单传值给临床
            patList[i].patientPhone = this.rowCurr.patientPhone || ''
            patList[i].patient.patientPhone = this.rowCurr.patientPhone || ''
            // patList[i].grade = this.rowCurr.grade || ''
            // patList[i].PrivacyLevel = this.rowCurr.PrivacyLevel || this.rowCurr.privacyLevel || ''
            // if (this.applyInfoHospital === 'wzszxyy') {
            patList[i].hbsag = this.rowCurr.hbsag || ''
            patList[i].hiv = this.rowCurr.hiv || ''
            patList[i].rpr = this.rowCurr.rpr || ''
            patList[i].hcv = this.rowCurr.hcv || ''
            patList[i].lisSerumGastric = this.rowCurr.lisSerumGastric || ''
            patList[i].creatinine = this.rowCurr.creatinine || ''
            if (((this.applyInfoHospital === 'wzszxyy' || this.hospitalCode === '47052555733030211A1001') && this.userDepartment === '超声科') || this.$hasPermission['YJYY10008056']) {
              this.getSplitContent(patList[i])
            }
            patList[i].remarkInfo = this.rowCurr.remarkInfo || ''
            if (Array.isArray(patList[i].examinations) && patList[i].examinations.length) {
              if (this.rowCurr.applyCode == patList[i].examinations[0].applyCode) {
                patList[i].examinations[0].remarkInfo = this.rowCurr.remarkInfo
              }
            } else {
              console.error('该患者没有检查项目')
            }
            // }
          }
        }
        let applyIdss = ''
        if (((this.applyInfoHospital === 'wzszxyy' || this.hospitalCode === '47052555733030211A1001') && this.userDepartment === '超声科') || this.$hasPermission['YJYY10008056']) {
          applyIdss = this.applyCodeFrom.join('$,$') || ''
        }
        // this.userDepartment === '超声科' ? applyIds = examItemChangeId.join('$,$') || '' : null
        console.warn('=======patList=========', patList)
        if ((this.applyInfoHospital === 'wzszxyy' || this.hospitalCode === '47052555733030211A1001') && patList && patList.length > 0 && patList.filter(item => item && (item.patientPhone === null || item.patientPhone === '' || item.patientPhone.length != 11) && item.patientSource != 2) != 0 && !this.isAlreadyShow) {
          this.isAlreadyShow = true
          this.$confirm('电话号码格式不正确请填写正确的电话号码', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.detail(patList)
          }).catch(() => {
            if (this.formdata.executeDepartMent === '内窥镜') {
              this.detail(patList[0])
            }
          })
        }
        if ((this.hospitalCode === '47052555733030211A1001' || this.applyInfoHospital === 'wzszxyy') && this.formdata.executeDepartMent === '内窥镜' && patList && patList.length > 0 && patList.filter(item => item && (item.patientPhone === null || item.patientPhone === '' || item.patientPhone.length != 11)).length === 0 && !this.isAlreadyShow && !this.isShowDayTag) {
          this.isAlreadyShow = true
          this.detail(patList[0])
        }
        this
        const data = {
          hospitalCode: this.hospitalCode,
          hospitalName: this.hospitalName,
          patientId: row.patientId,
          inPatientId: row.hospizationCode,
          operateUser: userInfo.userName,
          operateCode: userInfo.userCode,
          examClass: row.examClass,
          idCard: row.idCard,
          applyCode: applyIdss != '' ? applyIdss : applyIds,
          appointmentType: this.formdata.fromCheckDepartment ? '检查科室' : this.appoint_type,
          tel: '',
          ps: row.patientSource,
          pw: 0, // 0 病人id 1 卡号 2 门诊号 3 住院号 4 发票号 5 申请单号 6 身份证号 7 社保卡号 暂时不用 8 手机号 默认0
          edm: row.examExecuteDepartment,
          isLogo: 1,
          yeFlag: 1,
          registerRoom: checkBed,
          // 当前选择患者的所有申请单数据
          patientList: patList ? enc.AESEncrypt(JSON.stringify(patList), '3c837d501a8f49b1') : []
        }
        if (window.g.UNRELOAD_APPO_EXAM) {
          this.applyCheckUrl = ''
          setTimeout(() => {
            this.applyCheckUrl = this.getCheckUrl()
            setTimeout(() => {
              data.registerRoom = this.setOverBed.isOverBed ? '' : data.registerRoom
              data.appointmentType = this.formdata.fromCheckDepartment ? '检查科室' : data.appointmentType
              // this.resetBtn()
              this.$emit('checkPostMsg', data)
            }, 500)
          }, 200)
        } else {
          data.registerRoom = this.setOverBed.isOverBed ? '' : data.registerRoom
          data.appointmentType = this.formdata.fromCheckDepartment ? '检查科室' : data.appointmentType
          // this.resetBtn()
          this.$emit('checkPostMsg', data)
        }
      }
    },
    handleInit() {
      this.checkedPatId = ''
      this.applyCodes = ''
      this.selectRowIds = []
      // this.rowCurr = {}
      // this.$store.dispatch('patient/setRowCurr', {})
    },
    listInit() {
      this.handleInit()
      this.tableDataAll = []
      this.tableDataShowAll = this.tableDataAll
      this.filterList()
      this.applyCheckUrl = ''
      this.timeout08 = setTimeout(() => {
        this.applyCheckUrl = this.getCheckUrl()
      }, 200)
    },
    // 获取已选择的申请单数据，传给临床预约页面展示用
    getCheckedPatList(applyCodes) {
      const acs = applyCodes.split('$,$')
      if (acs.length > 0) {
        return acs.map(a => {
          return this.tableDataAll.find(l => l.applyCode === a)
        })
      }
      return null
    },
    // 住院服务中心和转诊的提示(温州市中心医院的功能)
    tipHaveLevelFunction(data) {
      // if (!item.checked) return
      let adName = '住院服务中心'
      let appointType = '转诊'
      // if (process.env.NODE_ENV != 'production') {
      //   adName = '住院服务中心'
      // }
      for (let i = 0; i < data.length; i++) {
        if ((data[i].applyDepartment.toString().indexOf(adName) > -1 || (data[i].wardName && data[i].wardName != null && data[i].wardName.toString().indexOf(adName) > -1)) && data[i].patientSource == 2) {
          // this.$refs.formQueryTextIpt && this.$refs.formQueryTextIpt.blur()
          // this.$refs.patientName && this.$refs.patientName.blur()
          window.document.activeElement.blur() // 让当前聚焦中的元素失去光标（有效果）
          // window.blur() // 让浏览器失去光标（这个代码并没效果）
          // this.$alert('该患者为日间病房患者，请优先预约', '温馨提示', {
          //   confirmButtonText: '确定',
          //   callback: action => {
          //     // this.$message({
          //     //   type: 'info',
          //     //   message: `action: ${action}`
          //     // })
          //   }
          // })
          this.$confirm('该患者为日间病房患者，请优先预约', '温馨提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            if (this.formdata.executeDepartMent === '内窥镜') {
              this.detail(data[i])
            }
          })
          break
        } else if (data[i].appointmentType.toString().indexOf(appointType) > -1) {
          window.document.activeElement.blur()
          this.$alert('该病人是转诊病人已登记，是否继续登记', '温馨提示', {
            confirmButtonText: '确定',
            callback: action => {
              // this.$message({
              //   type: 'info',
              //   message: `action: ${action}`
              // })
            }
          })
          break
        }
      }
    },
    // 联合预约
    appointmentPostMessageUnion() {
      if (this.hisActivedIndex === 1) {
        let checkIds = []
        this.applyCodes = ''
        let _row = null
        // this.tableData.forEach(item => {
        this.mix_tableData.forEach(item => {
          if (item.patientId === this.checkedPatId && item.checked) {
            checkIds.push(item.applyCode)
            if (!_row) {
              _row = item
            }
          }
        })
        // console.log('_row', _row)
        if (isNull(_row)) {
          if (!isNull(this.rowCurr)) {
            _row = this.rowCurr
            checkIds.push(_row.applyCode)
            // console.log('checkIds', checkIds)
          }
        }
        if (_row) {
          this.selectRowIds = checkIds
          this.applyCodes = checkIds.join('$,$')
          // console.log('this.applyCodes', this.applyCodes)
          // console.log('_row', _row)
          this.appointmentPostMessage(_row)
        }
      } else if (this.hisActivedIndex === 2 || this.hisActivedIndex === 3) {
        this.$store.dispatch('patient/setHisActivedIndex', 1)
        this.$parent.$parent.btnTypeChange(1)
      }
    },
    // 触发列表数据
    handleRowCurr(row, column, event) {
      console.log('handleRowCurr', row, column, event)
      // let objCurr = Object.assign({}, this.rowCurr, { isJZ: false, isVIP: false, privacyLevel: '' })
      // this.$store.commit('patient/SETROWCURR', objCurr)
      this.$store.commit('patient/SETROWCURR', { isJZ: this.isJZ, isVIP: this.isVIP, privacyLevel: '' })
      this.$store.commit('patient/SELECTEDPATIENTINFO', {})
      if (this.appConfig.baseConfig && this.appConfig.baseConfig.mpi) {
        this.mipVisible = this.appConfig.baseConfig.mpi
      }
      this.applyMRIChange(row)
      this.applyCodes = ''
      if (column && column.type === 'index' && column.index === 0) {
        if (this.isCheckExamStatus && row.examStatus >= 0 && row.examStatus <= 3 && this.hisActivedIndex == 1) {
          // 从/api/hospital/getappsettings接口获取IsCheckExamStatus的值，
          // 当IsCheckExamStatus=true时，判断申请单的状态ExamStatus >= 0 && ExamStatus <= 3的为已预约数据，
          // 查询号源和预约的时候别传这些已预约数据
          // examStatus	integer($int32) -1 - HIS取消 0 - 已登记 1 - 已检查 2 - 已报告 3 - 已审核 4 - 已作废 5 - 原始 必填
          return
        }
        if (!!this.checkedPatId && this.checkedPatId !== row.patientId) {
          // 如果已经选择，且点击的不是同一个患者
          return
        }
        let tableArr = []
        if (!this.checkedPatId) {
          tableArr = JSON.parse(JSON.stringify(this.tableDataAll.filter(item => item.patientId === row.patientId)))
          tableArr.forEach((item) => {
            if (row.emergencyLabel || row.emergencylabel) {
              item.grade = row.grade
              item.emergencyLabel = row.emergencyLabel || row.emergencylabel
              item.emergencylabel = row.emergencyLabel || row.emergencylabel
              item.emergency = row.emergency
            }
          })
        } else {
          tableArr = this.mix_tableData
        }
        let patId = ''
        tableArr.forEach(item => {
          if (item.applyCode === row.applyCode) {
            item.checked = !item.checked
          }
          if (item.checked) {
            patId = item.patientId
          }
        })
        this.checkedPatId = patId
        if (!this.checkedPatId) {
          this.tableDataShowAll = this.tableDataAll
          this.filterList()
        } else {
          this.tableDataShowAll = tableArr
          this.filterList()
        }
        this.checkallChange()
      }
      row.emergencylabel = this.getLevel(~~row.emergency)
      if (row.emergencylabel == 'VIP') {
        this.isVIP = true
      } else {
        this.isVIP = false
      }
      row.isVIP = this.isVIP
      if (row.emergencylabel == '急诊') {
        this.isJZ = true
      } else {
        this.isJZ = false
      }
      row.isJZ = this.isJZ
      console.log('======row=>1', row)
      let newRow = this.setRowCurrEvent(row)
      bus.$emit('selectedRowCurr', newRow)
      // // console.log('触发一次selectedRowCurr=>handleRowCurr')
      this.$store.commit('patient/SELECTEDPATIENTINFO', newRow)
      if (!isNull(newRow)) {
        this.isSelectedRow = true
      }
      if (this.isCheckExamStatus && row.examStatus >= 0 && row.examStatus <= 3 && this.hisActivedIndex == 1 || this.selectRowIds.includes(row.applyCode)) {
        // 从/api/hospital/getappsettings接口获取IsCheckExamStatus的值，
        // 当IsCheckExamStatus=true时，判断申请单的状态ExamStatus >= 0 && ExamStatus <= 3的为已预约数据，
        // 查询号源和预约的时候别传这些已预约数据
        // examStatus	integer($int32) -1 - HIS取消 0 - 已登记 1 - 已检查 2 - 已报告 3 - 已审核 4 - 已作废 5 - 原始 必填
        return
      }
      this.selectRowIds = [row.applyCode]
      this.applyCodes = row.applyCode
      if ((this.hospitalCode === '47052555733030211A1001' || this.applyInfoHospital === 'wzszxyy') && this.formdata.executeDepartMent === '内窥镜') {
        this.detail(row)
      }
      // console.log('this.isSetGrade', this.isSetGrade)
      if (this.isSetGrade) {
        let _row = JSON.parse(JSON.stringify(row))
        _row.emergency = row.emergencyCopyFlag
        this.appointmentPostMessage(_row)
      } else {
        this.appointmentPostMessage(row)
      }
    },
    handleRowCurr2(row, column, event) {
      // console.log('handleRowCurr2=>row', row)
      if (this.appConfig.baseConfig && this.appConfig.baseConfig.mpi) {
        this.mipVisible = this.appConfig.baseConfig.mpi
      }
      this.applyMRIChange(row)
      this.applyCodes = ''
      if (column && column.type === 'index' && column.index === 0) {
        if (this.isCheckExamStatus && row.examStatus >= 0 && row.examStatus <= 3 && this.hisActivedIndex == 1) {
          // 从/api/hospital/getappsettings接口获取IsCheckExamStatus的值，
          // 当IsCheckExamStatus=true时，判断申请单的状态ExamStatus >= 0 && ExamStatus <= 3的为已预约数据，
          // 查询号源和预约的时候别传这些已预约数据
          // examStatus	integer($int32) -1 - HIS取消 0 - 已登记 1 - 已检查 2 - 已报告 3 - 已审核 4 - 已作废 5 - 原始 必填
          return
        }
        if (!!this.checkedPatId && this.checkedPatId !== row.patientId) {
          // 如果已经选择，且点击的不是同一个患者
          return
        }
        let tableArr = []
        if (!this.checkedPatId) {
          tableArr = JSON.parse(JSON.stringify(this.tableDataAll.filter(item => item.patientId === row.patientId)))
          tableArr.forEach((item) => {
            if (row.emergencyLabel || row.emergencylabel) {
              item.grade = row.grade
              item.emergencyLabel = row.emergencyLabel || row.emergencylabel
              item.emergencylabel = row.emergencyLabel || row.emergencylabel
              item.emergency = row.emergency
            }
          })
        } else {
          tableArr = this.mix_tableData
        }
        let patId = ''
        tableArr.forEach(item => {
          if (item.applyCode === row.applyCode) {
            item.checked = !item.checked
          }
          if (item.checked) {
            patId = item.patientId
            // this.tipLevelFunction(item)
          }
        })
        this.checkedPatId = patId
        if (!this.checkedPatId) {
          this.tableDataShowAll = this.tableDataAll
          // this.rowCurr = {}
          // this.$store.dispatch('patient/setRowCurr', '')
          // console.log('filterList=>handleRowCurr2')
          // this.filterList()
        } else {
          this.tableDataShowAll = tableArr
          // console.log('filterList=>handleRowCurr2')
          this.filterList()
        }
        this.checkallChange()
      }
      row = this.setCheckedInitStatus(row)
      let newRow = this.setRowCurrEvent(row)
      bus.$emit('selectedRowCurr', newRow)
      this.$store.commit('patient/SELECTEDPATIENTINFO', newRow)
      if (this.isCheckExamStatus && row.examStatus >= 0 && row.examStatus <= 3 && this.hisActivedIndex == 1 || this.selectRowIds.includes(row.applyCode)) {
        // 从/api/hospital/getappsettings接口获取IsCheckExamStatus的值，
        // 当IsCheckExamStatus=true时，判断申请单的状态ExamStatus >= 0 && ExamStatus <= 3的为已预约数据，
        // 查询号源和预约的时候别传这些已预约数据
        // examStatus	integer($int32) -1 - HIS取消 0 - 已登记 1 - 已检查 2 - 已报告 3 - 已审核 4 - 已作废 5 - 原始 必填
        return
      }
      this.selectRowIds = [row.applyCode]
      this.applyCodes = row.applyCode
    },
    setRowCurrEvent(data) {
      let row = {
        patientName: this.formdata.patientName,
        patientSource: this.formdata.patientSource,
        queryWay: this.formdata.queryWay,
        queryText: this.formdata.queryText
      }
      Object.keys(row).forEach(key => {
        if (!row[key]) {
          delete row[key]
        }
      })
      // if (!row.patientName) {
      //   delete row.patientName
      // }
      // executeDepartMent: this.formdata.executeDepartMent
      // if (this.formdata.executeDepartMent) {
      //   row.executeDepartMent = this.formdata.executeDepartMent
      // }
      let newRow = Object.assign({}, this.rowCurr, row, data)
      if (newRow.executeDepartMent) {
        delete newRow.executeDepartMent
      }
      // newRow.hbsag ? newRow.hbsag = '阴性' : null
      // newRow.hiv ? newRow.hiv = '阴性' : null
      // newRow.rpr ? newRow.rpr = '阴性' : null
      // newRow.hcv ? newRow.hcv = '阴性' : null
      newRow.emergencylabel = this.getLevel(~~newRow.emergency)
      // // // console.log('======row=>4', newRow)
      this.$store.commit('patient/SETROWCURR', newRow)
      return newRow
    },
    applyMRIChange(row) {
      if (this.$refs.applymriState) {
        this.$refs.applymriState.applyMRITableVisible = false
        if (row.examClass && row.patientSource === 1 && row.medicalCardNo && this.MRI_examClass && this.MRI_examClass.includes(row.examClass)) {
          this.$refs.applymriState.applyMRITableVisible = true
          const mcNo = enc.SM2Encrypt(row.medicalCardNo, this.pubcliKey)
          const data = {
            organizationCode: row.organizationCode, // 申请医院代码
            patientSource: row.patientSource, // 病人类型 1 门诊 2 住院 3 体检 4 绿检 5急诊 6外院、0未知 默认0
            dep: row.examClass, // 检查部门
            medicalCardNo: '04' + mcNo // 就诊卡号 需加密
          }
          // // // // console.log('applyMRIChange', data)
          this.$refs.applymriState.init(data)
        }
      }
    },
    cancelHisApply() {
      console.log('this.checkedPatId', this.checkedPatId)
    },
    cancelCheckedChange() {
      this.isJZ = false
      this.isVIP = false
      let objCurr = Object.assign({}, this.rowCurr, { isJZ: false, isVIP: false, privacyLevel: '' })
      this.$store.commit('patient/SETROWCURR', objCurr)
      this.handleInit()
      this.formdata.fromCheckDepartment = false
      this.tableDataShowAll = this.tableDataAll
      this.filterList()
      this.checkAll = false
      this.isIndeterminate = false
      this.refreshIframeContent = true
      this.$emit('refreshIframe', this.refreshIframeContent)
    },
    iframePMBack(data) {
      if (data.type === 1 && !(data.isSaveInput)) {
        this.cancelCheckedChange()
        this.isSaveInput = false
        this.formdata.queryText = ''
        this.formdata.patientName = ''
        let checkFormDefault = getLocalStorage(CHECK_FORM_DEFAULT_KEY)
        this.formdata.dateRadio = checkFormDefault ? JSON.parse(checkFormDefault).dateRadio : '7'
        let day = ~~this.formdata.dateRadio
        this.formdata.hisFormDate = [getDateYMD(new Date().getTime() - Math.abs(day - 1) * 24 * 60 * 60 * 1000), getDateYMD(new Date().getTime())]
        console.log('iframePMBack=>patient/SETROWCURR')
        console.log('this.rowCurr', this.rowCurr)
        let objCurr = Object.assign({}, this.rowCurr, { isJZ: false, isVIP: false, privacyLevel: '' })
        this.$store.commit('patient/SETROWCURR', objCurr)
        this.timeout09 = setTimeout(() => {
          this.isVIP = false
          this.isJZ = false
        }, 200)
        this.$forceUpdate()
        this.handleInit()
        if (this.notAutoSearchPatSource && this.notAutoSearchPatSource.length) {
          const resultIndex = this.notAutoSearchPatSource.indexOf(this.formdata.patientSource)
          if (resultIndex > -1) {
            this.vt_init([])
          } else {
            this.getHisExamList()
          }
        } else {
          this.getHisExamList()
        }
      } else if (data.type === 1 && data.isSaveInput) {
        // 如果是机房排队号预约的，则不清空左侧里用来筛选的数据
        this.isSaveInput = true
        this.getHisExamList()
      }
    },
    // wsChange(data) {
    //   // this.wsType = data.type
    //   // type: 'ybpzsmk',name: '市民卡'; type: 'dzybpz/dzybpz-fj',name: '医保凭证'; type: 'sbjzfds-fj',name: '磁条卡'
    //   // type: ['sbjzykt-fj', 'sbjzykt-fj'],name: '市民卡'
    //   if (data.type === 'dzybpz' || data.type == 'dzybpz-fj' || data.type == 'dzybpz-tz') { // 医保凭证
    //     this.formdata.queryWay = 6
    //   } else if (data.type === 'sbjzfds-fj' || data.type === 'sbjzykt-fj') { // 市民卡、磁条卡
    //     this.formdata.queryWay = 1
    //   } else if (data.type === 'jkk') { // 健康卡
    //     this.formdata.queryWay = 1
    //   } else {
    //     this.formdata.queryWay = 1
    //   }
    //   this.$refs.formQueryTextIpt && this.$refs.formQueryTextIpt.focus()
    //   // this.$refs.formQueryTextIpt && this.$refs.formQueryTextIpt.blur()
    //   // window.document.getElementById('formQueryTextIpt').blur()
    //   // // // console.log('光标移出=>formQueryTextIpt.blur()')
    //   // window.document.activeElement.blur() // 让页面所有元素失去光标
    //   // // // console.log('光标移出=>document.activeElement.blur()')
    //   this.setPatientSourceToqueryWay()
    // },
    // 获取急诊标志
    getEmergencyTip(emerVal) {
      let returnTip = emerVal === 1 && window.g.isShowEmergencyLimit ? '四级急诊' : this.emergencyOptionsMap[emerVal]
      return returnTip
    },
    // 获取优先级
    getLevel(level) {
      // if (window.g.ISUSE_DEFAULTSTEPTIME) {
      const emerValChange = [14, 15, 16]
      level = emerValChange.includes(level) ? '1' : level
      // }
      // return Options.emergencyOptionsMap[level]
      return this.emergencyOptionsMap[level]
    },
    // 获取急诊标志的标签，例如普通 术前
    renderEmergencyInt(emerVal) {
      emerVal = emerVal || '普通'
      // return Options.emergencyOptionsRevertMap[emerVal]
      return this.emergencyOptionsRevertMap[emerVal]
    },
    getSource(row, column, val) {
      val = ~~val
      // return Options.emergencyOptionsRevertMap[val]
      return this.emergencyOptionsRevertMap[val]
    },
    getGender(gender) {
      switch (gender) {
        case 1:
        case '1':
          return '男'
        case 2:
        case '2':
          return '女'
        default:
          return ''
      }
    },
    getExamStatusVal(status) {
      // -1 - HIS取消 0 - 已登记 1 - 已检查 2 - 已报告 3 - 已审核 4 - 已作废 5 - 原始 必填
      switch (status) {
        case -1:
          return 'HIS取消'
        case 0:
          return '已登记'
        case 1:
          return '已检查'
        case 2:
          return '已报告'
        case 3:
          return '已审核'
        case 4:
          return '已作废'
        case 5:
          return '未登记'
        default:
          return '未登记'
      }
    },
    getPatAge(row, column, val) {
      if (val) {
        if (val.indexOf('Y')) {
          return val.replace('Y', '岁')
        } else if (val.indexOf('M')) {
          return val.replace('M', '月')
        } else if (val.indexOf('D')) {
          return val.replace('D', '日')
        }
      }
      return val
    },
    getParamsString(data) {
      const d = Object.keys(data).map(k => { return `${k}=${data[k]}` })
      return d.join('&')
    },
    getViolationCount(info) {
      let extraSubstr = 0
      if (info && info.extras && info.extras.length > 0) {
        info.extras.forEach(element => {
          if (element.key == 'violationcount') {
            extraSubstr = element.value
          }
        })
      }
      return extraSubstr
    },
    // 设置展开菜单的高度，根据费用明细的条数来控制
    getHeight(orderBill) {
      let orderHeight = ''
      if (orderBill.length === 1) {
        orderHeight = 65
      } else if (orderBill.length === 2 || orderBill.length === 3) {
        orderHeight = 65 * orderBill.length - 8
      } else {
        orderHeight = 55 * orderBill.length - 8
      }
      return orderHeight ? orderHeight.toString() + 'px' : '20px'
    },
    // 全选功能的交互
    handleBillCheckedAll(row, checkedAll) {
      if (row.orderBillInfo && row.orderBillInfo.length > 0) {
        row.orderBillInfo.forEach(element => {
          element.checked = !element.checked
        })
        row.orderCheckedAll = checkedAll
      }
      if (row.orderCheckedHalf) {
        row.orderCheckedAll = true
        row.orderCheckedHalf = false
        row.orderBillInfo.forEach(element => {
          element.checked = true
        })
      }
    },
    // 去掉一个勾选，全选的状态
    handleBillChecked(item, index, checked) {
      // 更新单个复选框的状态
      const targetExamItemNo = item.orderBillInfo[index].examItemNo
      // 医技序号相同的勾选状态也同步
      item.orderBillInfo.forEach(element => {
        if (element.examItemNo === targetExamItemNo) {
          element.checked = checked
        }
      })
      // 深拷贝改变原有数组的样子
      let foundRow = this.tableDataAll.find(row => row.applyCode === item.applyCode)
      if (foundRow) {
        foundRow.orderBillInfo = item.orderBillInfo
      }
      // 更新全选复选框的状态
      const checkedCount = item.orderBillInfo.filter(i => i.checked).length
      item.orderCheckedAll = checkedCount === item.orderBillInfo.length
      item.orderCheckedHalf = checkedCount > 0 && checkedCount < item.orderBillInfo.length
      // console.error('item', item)
    },
    getSplitContent(patListItem) {
      // console.error('patListItem', patListItem)
      let patListContent = JSON.parse(JSON.stringify(patListItem))
      let examParts = []
      let applyCodeNow = patListItem.applyCode.split(',').length > 0 && patListItem.applyCode.split(',')[0].split('_').length > 0 ? patListItem.applyCode.split(',')[0].split('_')[0] : patListItem.applyCode
      let applyCodeSolve = []
      let costs = 0
      // 收费项目明细的处理
      const commonItems = patListItem.orderBillDetails.filter(item1 =>
        patListItem.orderBillInfo.some(item2 => item1.examItemNo === item2.examItemNo && item2.checked)
      )
      patListItem.orderBillDetails = JSON.parse(JSON.stringify(commonItems))
      // 检查项目明细的处理
      const commonExams = patListItem.examItems.filter(item1 =>
        patListItem.orderBillDetails.some(item2 => item1.examItemNo === item2.examItemNo)
      )
      patListItem.examinations[0].examItems = patListItem.examItems = JSON.parse(JSON.stringify(commonExams))
      // examPart，examItemName(两者相同)
      commonExams.forEach((element, index) => {
        examParts.push(element.examItemName)
        applyCodeSolve[index] = applyCodeNow + '_' + patListItem.examClass + '_' + element.examItemNo
      })
      commonItems.forEach((element, index) => {
        costs = costs + element.price
      })
      patListItem.cost = JSON.parse(JSON.stringify(costs))
      patListItem.examItemName = patListItem.examPart = examParts.join(',')
      // applyCode申请单号
      if (applyCodeSolve.join('-').startsWith('-')) {
        const applyContent = applyCodeSolve.join('-').substring(1)
        patListItem.applyCode = JSON.parse(JSON.stringify(applyContent))
      } else {
        patListItem.applyCode = JSON.parse(JSON.stringify(applyCodeSolve.join('-')))
      }
      patListItem.examinations[0].applyCode = applyCodeSolve.join(',')
      patListItem.examinations[0].cost = JSON.parse(JSON.stringify(costs))
      delete patListItem.orderBillInfo
      delete patListItem.orderCheckedAll
      delete patListItem.orderCheckedHalf
      // console.warn('applyCodeSolve', applyCodeSolve)
      this.applyCodeFrom.push(applyCodeSolve.join(','))
      // console.warn('patListContent', patListContent, commonExams)
      return patListContent
    }
  }
}
</script>

<style lang="scss" scoped>
$primaryColor: #00A4E9;
$tableThBgColor: #eff6fe;
$warningColor: #ff7600;
$tableSlectedBgColor: #ffe3cc;
$tableDangerColor: #f00;
.el-button+.el-button{
  margin-left: 5px;
}
.his_container{
  padding: 0;
  margin: 0;
  position: relative;
  background-color: #f5f6fa;
  height: 100%;
  overflow-y: auto;
  padding-bottom: 40px;
  h1{
    margin: 0;
  }
  /deep/ .el-table__body tr.current-row>td{
    background-color: $warningColor;
    color: #fff;
  }
  /deep/ .ky-table th{
    background-color: $tableThBgColor;
    color: #333;
    font-weight: 500;
  }
  /deep/ .el-table__body tr.select-row>td {
    background: $tableSlectedBgColor;
  }
  /deep/ .el-table__body tr.danger-row>td {
    color: $tableDangerColor;
  }
}
.apply_form{
  padding: 6px 10px;
  border-bottom: solid 1px #dbdcde;
  background-color: #f2f6fc;
  position: relative;
  .more_btn{
    font-size: 14px;
    color: #999;
    text-align: center;
    background-color: #fff;
    display: inline-block;
    width: 30px;
    line-height: 30px;
    cursor: pointer;
    &.more_btn_active{
      color: #00A4E9;
    }
    &:hover{
      color: #00A4E9;
    }
  }
  /deep/ .el-form-item__content{
    height: 30px;
    line-height: 30px;
  }
  /deep/ .el-form--inline .el-form-item {
    margin: 4px 0;
  }
  /deep/ .el-radio{
    margin-right: 10px;
  }
  /deep/ .el-button--primary{
    background-color: $warningColor;
    border-color: $warningColor;
  }
  /deep/ .el-button--primary:focus,
  /deep/ .el-button--primary:hover{
    background-color: $warningColor;
  }
  /deep/ .el-radio-button__orig-radio:checked+.el-radio-button__inner{
    background-color: $warningColor;
  }
  /deep/ .el-input--mini .el-input__inner{
    line-height: 30px;
    height: 30px;
  }
  /deep/ .el-range-editor--mini.el-input__inner{
    line-height: 30px;
    height: 30px;
  }
  /deep/ .el-button--mini, .el-button--mini.is-round{
    padding: 8px 15px;
  }
}
.his_table{
  padding: 0 10px;
}
.grid_tit{
  /* padding: 10px 0; */
  padding: 5px 0;
  font-size: 15px;
  color: #333;
  .tips{
    font-size: 12px;
    color: #999;
  }
  .grid-tit-tip{
    padding: 7px 0;
    // float: left;
    // line-height: 29px;
  }
  .grid_tit_ckb{
    display: inline-block;
    /deep/ .el-checkbox{
      margin-right: 6px;
    }
  }
}
.his_cont{
  background-color: #ebeef5;
  /deep/ .el-radio__label{
    padding-left: 5px;
    font-size: 12px;
  }
  /deep/ .el-radio__input.is-checked+.el-radio__label{
    color: $warningColor;
  }
  /deep/ .el-radio__input .el-radio__inner:hover{
    border-color:  $warningColor;
  }
  /deep/ .el-radio__input.is-checked .el-radio__inner{
    border-color:  $warningColor;
    background:  $warningColor;
  }
  /deep/ .el-table__body-wrapper {
    height: 300px;
    overflow-y: auto;
  }
  /deep/ .el-table td,/deep/ .el-table th{
    padding: 4px 0;
  }
}
.pat_source{
  display: inline-block;
  vertical-align: 1px;
  height: 30px;
  line-height: 28px;
  border: solid 1px #e5e5e5;
  padding: 0 0 2px 8px;
  background-color: #fff;
}
.check_appo_card{
  /deep/ .el-card__body{
    padding: 0;
  }
}
.pat_info{
  width: 100%;
  height:100%;
  padding: 0 10px 10px;
  background-color: #f5f6fa;
  border-top: solid 1px #e5e5e5;
  .pat_info_item{
    display: flex;
    flex-wrap: wrap;
  }
}
// /deep/ .el-checkbox__label {
//   padding-left: 5px !important;
// }
// @media screen and (max-width: 1280px) {
//   .his_cont /deep/ .el-table__body-wrapper{
//     height: 200px;
//   }
// }

.his_cont .ky-table /deep/ .el-table__body-wrapper::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 6px;
  /*高宽分别对应横竖滚动条的尺寸*/
  height: 8px;
}
/deep/ .el-tag--dark.el-tag--danger {
  background: #f5534f;
  border-color: #f5534f;
  margin-right: 5px;
}
.fc_red2 {
  background: #f5534f !important;
}
.ft0 {
  font-size: 0;
  span, b, i{
    font-size:14px
  }
}
.apply_form /deep/ .el-input-group__prepend {
  padding: 0 15px;
}
.el-table-wrappers {
  position: relative;
  // height: 334px;
  // padding-bottom: 5px;
}
.draggerVbar{
  height: 3px;
  position: absolute;
  right: -10px;
  left:-10px;
  bottom: 0;
  z-index: 5;
  cursor: ns-resize;
  background: #ebeaea;
  &:hover{
    background-color: rgba(0, 163, 233, 0.192);
  }
  &:active{
    background-color: #00A4E9;
  }
}
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
.ky-table >>> .text-underline {
  text-decoration: line-through;
}
.nested-table-container{
  overflow: scroll;
}

.his_table .el-table /deep/  .blue-row td:nth-child(n+1) div.cell {
  color: #4c97dd !important;
}
.his_table .el-table /deep/  .purple-row td:nth-child(n+1) div.cell {
  color: #ac23fd !important;
}
.his_table .el-table /deep/  .green-row td:nth-child(n+1) div.cell {
  color: #198c04 !important;
}
.his_table .el-table /deep/  .red-row  td:nth-child(n+1) div.cell {
  color: #f37356 !important;
}
.his_table .el-table /deep/  .lightgreen-row td:nth-child(n+1) div.cell {
  color: #08cfc7 !important;
}
.his_table .el-table /deep/  .blue-font td:nth-child(n+1) div.cell {
  color: #1d46ef !important;
}
.his_table .el-table /deep/  .yellow-row td:nth-child(n+1) div.cell {
  color: #f1ac2f !important;
}
</style>
